Rename Files
Join the DZone community and get the full member experience.
Join For Free
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
Opinions expressed by DZone contributors are their own.
Comments