python reモジュールは画像に統一的に名前を付けます

3981 ワード

フォルダを元の1に戻す.jpg,2.jpg、統一命名は000001.jpg,000002.jpg,,,,,
//dire   ,2802      
import os
import numpy as np
import re

dire = r'E:\pic\20180729'
#input_folder='/home/XXX/tensorflow/Python-Machine-Learning-Cookbook-master/Chapter09/training_images'
a=os.listdir(dire)
c=[]

for i in range(2802):
    a[i]=dire+'\\'+a[i]
    print(a[i])
b=[0*i for i in range(2802)]
pos = 6
for i in range(2802):
    c = str(i)
    ze = pos-len(c)
    b[i] = '0'*ze+str(i)
    b[i]=dire +'\\'+b[i]+'.jpg'
    os.rename(a[i],b[i])