python修改图片名

1 import glob
2 import os
3 
4 inputPath = r'E:/data/pic/cat'
5 fileList = glob.glob(inputPath + '/*')
6 cnt = 0
7 for path in fileList:
8     os.rename(path, inputPath+'/'+str(cnt).zfill(6)+path[path.rfind('.'):])
9     cnt +=1

 

posted @ 2020-03-01 14:44  小雨点1206  Views(627)  Comments(0Edit  收藏  举报