可以实现给文件夹内的图片重新命名
# -*- coding: utf-8 -*-
#修改文件夹中图像的名字,重新命名
import os
path = "/home/robot/pictures/img_tracker"
filelist = os.listdir(path)
count=0
for file in filelist:
print(file)
for file in filelist:
Olddir=os.path.join(path,file)
if os.path.isdir(Olddir):
continue
filename=os.path.splitext(file)[0]
filetype=os.path.splitext(file)[1]
Newdir=os.path.join(path,str(count).zfill(2)+filetype)
os.rename(Olddir,Newdir)
count+=1