#Cerca i file relativi alle immagini delle lettere DATINI e le copia #%% import csv import os import os.path import shutil import glob output = open('images_notfound.csv', 'w') csvwriter = csv.writer(output) params = ['CODICE'] csvwriter.writerow(params) #%% #rootdir = os.getcwd() csv_lettere = open('C:\\Users\\OVI-CNR\\Desktop\\Immagini Datini\\estrazione_immagini_1.csv') reader = csv.DictReader(csv_lettere) for row in reader: line = [] codice = row['CODICE'] for subdir, dirs, files in os.walk("Z:\\IMMAGINI DATINI"): for file in files: #print os.path.join(subdir, file) filepath = subdir + os.sep + file if filepath.__contains__(codice): line.append (codice) shutil.copy(filepath, 'C:\\Users\\OVI-CNR\\Desktop\\extracted_images') else: print (codice + " not found") csvwriter.writerow(line) output.close()