import os from PIL import Image path = './hr/' cnt =1 file_list = os.listdir(path) for i in range(len(file_list)): path_l = path+file_list[i]+'/hr0.png' path_r = path + file_list[i] + '/hr1.png' # print(path_) img =Image.open(path_r) #img.save('./0/',str(cnt)+'L.png') # img.save('./0/' + str(cnt) + 'L.png') img.save('./0/' + str(cnt) + 'R.png') cnt+=1