python之对指定目录文件夹的批量重命名 import os,shutil,string dir = "/Users/lee0oo0/Documents/python/test" #指定的目录 for i in os.listdir(dir): #遍历指定目录的文件 newfile = i.replace('a','b') # 替换 oldname = dir +'/'+str(i) newname = dir +'/'+str(newfile) shutil.move(oldnam…
#法一 import os path = "C://Python34//" for file in os.listdir(path): if os.path.isfile(os.path.join(path,file))==True: if file.find('.')<0: newname=file+'.jpg' os.rename(os.path.join(path,file),os.path.join(path,newname)) #法二 import os import…