纯粹自己记录下来怕脚本玩丢了,很简单的脚本,没考虑png格式,需要的出门别的博客看去
import cv2 as cv
import os
dir_path = '/mnt/data-ractified/all/ground-truth/results'
file_list = os.listdir(dir_path)
for file in file_list:
if not file.endswith('.jpg'):
print('start changing! ' + file)
ori_path = dir_path + '/' + file
cv_file = cv.imread(ori_path)
name,ext = file.split('.')
des_path = dir_path + '/' + name + '.jpg'
cv.imwrite(des_path,cv_file)
print('finished! '+file)
os.remove(ori_path)