Python批量重命名脚本

# FilesBatchRename.py
# 导入os库
import os

# 图片存放的路径
path = r"D:/temp"

# 遍历更改文件名
num = 1
for file in os.listdir(path):
    os.rename(os.path.join(path,file),os.path.join(path,str(num))+".jpg")
    num = num + 1

posted @ 2022-04-26 16:05  木子欢儿  阅读(38)  评论(0编辑  收藏  举报