import sys, os, csv
data_file = 'C:/Users/81080/Desktop/class.csv'
im_file = 'D:/class_im/'
fileNames_1 = os.listdir('D:/class_im/')
csvfile = open(data_file, 'r')
csvreader = csv.reader(csvfile)
key_url_list = [line[:2] for line in csvreader]
for i in range(14499,len(key_url_list)):
fileNames_1 = os.listdir('D:/class_im/')
(key, id) = key_url_list[i]
if key in fileNames_1:
os.rename(os.path.join(im_file, key), os.path.join(im_file, id) + ".jpg")