''' This script used to rename the file that you specified. Usage: rename.py parameter1 parameter2. parameter1 is the parent path(dir) of the file that you want to rename. parameter2 is the file type which you want to rename. ''' import os import re import sys
for f in filenames: #print f if re.search(regx,f)!=None: '''Split the filename and extension''' oldname=os.path.splitext(f)[0] #print'The old name is:', oldname ext=os.path.splitext(f)[1] #print'The extentsion is:',ext #new_name='SPC_'+oldname+'.'+file_type new_name=oldname+'.'+'JPEG' os.rename(path+'\\'+f,path+'\\'+new_name) for f in os.listdir(path): print f