How can I rename the following files:
abc_2000.jpg
abc_2001.jpg
abc_2004.jpg
abc_2007.jpg
into the following ones:
year_200
import os
import glob
path = 'C:\\Users\\yannk\\Desktop\\HI'
file_num = 0
for filename in glob.glob(os.path.join(path, '*.jpg')):
os.rename(filename, path + '\\' + str(file_num) + '.jpg')
file_num += 1
This is to rename all files in a folder to the indentation of their position in the folder you should be able to scrap this code up and use it for your purpose. THIS is for people who are on windows and therefore os.cwd or os.getcwd do not work