import cv2 import os for fi in os.listdir('./CCimage/'): I=cv2.imread('./CCimage/'+fi) cv2.imwrite('./CCimage/'+fi.split('.')[0]+'.png',I) os.remove('./CCimage/'+fi) print fi