def rename():
path = "./2/"
filelist = os.listdir(path)
total_num = len(filelist)
i = 1
for item in filelist:
if item.endswith('.png'):
old = os.path.join(os.path.abspath(path), item)
print('src', src)
new = os.path.join(os.path.abspath('./1/'), '' + str(i) + '.png')
print('dst', dst)
try:
# src: old name dst New name
os.rename(old, new)
i += 1
except:
continue