Rename files with Python using os.rename
import os
def changeName(path, cName):
i = 1
for filename in os.listdir(path):
print(path+filename, '=>', path+str(cName)+str(i)+'.jpg')
os.rename(path+filename, path+str(cName)+str(i).zfill(6)+'.jpg')
i += 1
changeName('real_images/','')
Leave a comment