import os
class ImageRename():
def __init__(self):
self.path = 'E:\\object_detection_learning\\data\\data1\\JPEGImages'
def rename(self):
filelist = os.listdir(self.path)
total_num = len(filelist)
i = 0
for item in filelist:
if item.endswith('.jpg'):
src = os.path.join(os.path.abspath(self.path), item)
dst = os.path.join(os.path.abspath(self.path), '0' + format(str(i), '0>3s') + '.jpg')
os.rename(src, dst)
print ('converting %s to %s ...' % (src, dst))
i = i + 1
print ('total %d to rename & converted %d jpgs' % (total_num, i))
if __name__ == '__main__':
newname = ImageRename()
newname.rename()
参考
[1]https://blog.csdn.net/lwplwf/article/details/78368229
[2]https://blog.csdn.net/wearge/article/details/77374150
[3]https://blog.csdn.net/gaohuazhao/article/details/60324715
[4]C++/python/matlabhttps://blog.csdn.net/u011574296/article/details/72956446
说明
图像批量下载工具:图片助手(ImageAssistant) 批量图片下载器https://chrome.google.com/webstore/detail/imageassistant-batch-imag/dbjbempljhcmhlfpfacalomonjpalpko/related?hl=zh-CN