[PYTHON] File name batch change

change_filename.py


import os
import glob

path = "./input_dir"
files = glob.glob(path + '/*')

for i, f in enumerate(files):
    os.rename(f, os.path.join(path, 'new_file-'+'{0:05d}'.format(i) +'.jpg'))
# new_file-00000.jpg , new_file-00001.jpg

Recommended Posts

File name batch change
File name batch conversion
[python] Change the image file name to a serial number
Execute Python script from batch file
__name__
Change your Mac terminal user name
Change batch settings with Mailman's withlist command