有时候遇到文件夹中很多文件,需要统一重命名为0001-9999样式,可以使用如下python代码,filepath根据自己的实际情况进行修改
import os
filepath = "C:\\Users\\Administrator\\Videos\\Captures\\"
filelist = os.listdir(filepath)
n = 1
for file in filelist:
m = '%04d' % n
oldname = filepath + file
newname = filepath + str(m) + '.png'
os.rename(oldname,newname)
print(oldname,'----------',newname)
n+=1
Copyright © 2013-2023 8a.hk All Rights Reserved. 八艾云 版权所有 中山市八艾云计算有限公司 粤ICP备14095776号 粤公网安备 44200002445359号
增值电信业务经营许可证编号:B1-20222012
代理域名注册服务机构:西部数码