平時需要統一一些副檔名,手動更改太麻煩,便寫了乙個將副檔名批量小寫的指令碼,如下:
這樣就不用手動調整啦......import os
import sys,getopt
opts,args=getopt.getopt(sys.ar**[1:],"p:s:")
floderpath=""
for op,value in opts:
if op == "-p":
floderpath=value
stfiles=os.listdir(floderpath)
for filename in stfiles:
tu=os.path.splitext(filename)
scrext=tu[1]
ext=scrext.lower()
src=floderpath+'/'+filename
dst=floderpath+'/'+tu[0]+ext
print(src+' ------> '+dst)
os.rename(src,dst)
print("success")
matlab批量修改副檔名
有時候matlab在儲存檔案的時候,擴充套件檔名一不小心會寫錯,導致批量生成的檔案格式或檔名不是想要的。例如處理完乙個影象庫的影象所有結果都儲存為了 jpg 格式結果,但是實際想處理完結果儲存為 mat 件。matlab修改批量修改副檔名如下 newname filename 1 end 4 mat...
批量更改檔案的副檔名
最近想做驗證碼識別,然後從正方教務系統上找了很多驗證碼,然後發現擴充套件名為gif,我想把他們轉換成jpg,30多個檔案手動轉好麻煩,於是用python寫了個指令碼 將該目錄下的gif的副檔名改為jpg import os 獲取該目錄下的所有檔案 files os.listdir forfile i...
linux使用rename批量修改副檔名
一.rename解決 1.ubuntu系統下 rename s c h 把當前目錄下的字尾名為.c的檔案更改為.h的檔案 如果要批量去掉字尾則 rename s c 這樣就會把當前資料夾下的字尾為.c的副檔名去掉 2.centos5.5系統下 rename c h c 把當前目錄下的字尾名為.c的檔...