批次將JPG改成jpg問題 - Linux

Table of Contents

用python來做的話,開個文字檔貼上下面的code,
chmod u+x 之後執行

#! /usr/bin/env python

import os, commands
stdout = commands.getstatusoutput('find . -name "*.JPG"')
items = stdout[1].split('\n')

for item in items:
str1 = item.rstrip('JPG')
print('rename ' + item + ' to ' + str1 + 'jpg')
os.rename(item, str1 + 'jpg')



--

All Comments

Robert avatarRobert2011-03-14
看這語法應該要 3.0 以上才行
不過 commands 在 3.0 卻又已經 deprecated, 所以...
Liam avatarLiam2011-03-14
感謝提供解法 不過在被閹割的nas裡面 要執行python應該要
Charlie avatarCharlie2011-03-15
下一些功夫@_@
Isabella avatarIsabella2011-03-17
看來好像要做嵌入式系統的應用?
Elizabeth avatarElizabeth2011-03-19
這語法試過在2.6是可以用的喔
John avatarJohn2011-03-22
2.6 裡要把 print 關鍵字先 mask 掉才能用吧
Frederica avatarFrederica2011-03-23
且 commands 從 2.4 就是 deprecated, 只是到 3.0 才刪掉