文章源代码来自于Ins博主 pure.python
#python program to rename all file names in your directory import os # input file directory os.chdir('D://') print(os.getcwd) COUNT = 1 def increment(): global COUNT COUNT = COUNT + 1 for f in os.listdir(): f_name, f_ext = os.path.splitext(f) f_name = 'rename' + str(COUNT) increment() new_name = '{} {}'.format(f_name, f_ext) os.rename(f, new_name)
本人的文档都是自我记录,以便日后查看。