Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

Python batch file rename

def batch_rename(dir_path):
    itemlist = os.listdir(dir_path)
    # 获取目录文件列表
    for item in itemlist:
        # 连接成完整路径
        item_path = os.path.join(dir_path, item)
        print(item_path)
        # 修改文件名
        if os.path.isfile(item_path):
            splitext = os.path.splitext(item_path)
            os.rename(item_path, splitext[0] + "-ShowMeAI" + splitext[1])
Source by www.showmeai.tech #
 
PREVIOUS NEXT
Tagged: #Python #batch #file #rename
ADD COMMENT
Topic
Name
2+6 =