rename files
import os print 'path?' path=raw_input() files0=[] files1=[] if os.path.isdir(path): if path[-1]!='\\': path=path+'\\' files=os.listdir(path) for file in files: if os.path.isfile(path+file): files0.append(file) #add old names which should be changed s=file+'.jpg'#how to rename files1.append(s) #add new names print file, s print 'Y or N?' s=raw_input() if s in ['y','Y']: i=0 for file in files0: print file os.rename(path+files0[i],path+files1[i]) i=i+1
Source