#python对目录下所有文件夹里的图片重新命名(001、002.bmp、…)
#coding=utf-8
import os
注释:源文件夹下图片名为I1.bmp ,I2.bmp,…I10.bmp,I11.bmp,…
#root_path = ‘C:\Users\zhang\Desktop\neww’
root_path = ‘./’
list=os.listdir(root_path)
print(list)
for filejianame in list:
filename = os.listdir(filejianame)
for i in filename:
temp = i[1:-4]
s =’%03d’ % int(temp)
os.rename(os.path.join(root_path+filejianame, i), os.path.join(root_path+filejianame, s+’.bmp’))
09-07
8555
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
08-29
1194
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
05-19
2040
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)