first_num = 1
files = sorted(glob.glob("*.exr"))
num = lambda files : int(re.sub("\\D", "", files))
files_sort = sorted(files, key=num)
#print(files_sort)
for i, old_name in enumerate(files_sort):
old_name_lib = old_name.split('.')
new_name1 = old_name_lib[0] + "." + old_name_lib[1] + "."
new_name2 = "{0:04d}.exr".format(i + first_num)
os.rename(old_name, new_name1 + new_name2)
print(old_name + " = " + new_name1 + new_name2)
No comments:
Post a Comment