文章源代码来自于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)

 

posted on 2019-02-21 09:21  Canvas2018  阅读(118)  评论(0编辑  收藏  举报