python 文件重命名
from glob import glob
import os
from tqdm import tqdm
imgpaths = sorted(glob("path/*.jpg"))
for i, imgpath in enumerate(tqdm(imgpaths)):
txtpath = imgpath.replace(".jpg",".txt")
srcname = imgpath.split("/")[-1].split(".")[0]
newname = "vat_en_%05d"%i
os.rename(imgpath, imgpath.replace(srcname,newname))
os.rename(txtpath, txtpath.replace(srcname,newname))