python批量重命名文件

#coding=gbkimport osimport redef file_extension(fromPath,extension,count): for root,dirs,files in os.walk(fromPath) : for file in files: ''' os.rename('C:\\face1\\'+file,"C:\\face1\\"+re.split('@',file)[0]) ''' os.rename('C:\\face1\\'+file,"C:\\face1\\"+file+".png") os.system('echo '+file+' >>'+ 'c:\\text.text')if __name__=='__main__': #num=0 fromPath='C:\\face1' extension='png' count=0 scriptPath=os.path.abspath('.') if os.path.exists(scriptPath+'size.txt'): os.remove(scriptPath+'size.txt') file_extension(fromPath,extension,count)

你可能感兴趣的:(python,重命名)