有时候遇到文件夹中很多文件,需要统一重命名为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-2021 8a.hk All Rights Reserved. 八艾云 版权所有 中山市八艾云计算有限公司 粤ICP备14095776号