批量将文件夹下图像的名字更改后转入另一文件夹内
2022-01-15 本文已影响0人
小小杨树
import os
from PIL import Image
path1 = 'C://Users/kiven/Desktop/img/hxt/' #
path2 = 'C:/Users/kiven/Desktop/img/imgs/' #
Line = os.listdir(path1)
for img in Line:
images = Image.open(path1 + img)
imgName = str(img)
sImgName = imgName[-9:-4]
print(sImgName)
images.save(sImgName + '.jpg')