#Cerca i file relativi alle immagini delle lettere DATINI e le copia #%% import csv from fileinput import filename import os import os.path import shutil #%% csv_lettere = open('C:\\Users\\OVI-CNR\\Desktop\\Immagini Datini\\datini_associate_images_2.csv') reader = csv.DictReader(csv_lettere) for row in reader: line = [] filename_1 = row['filename_1'] filename_2 = row['filename_2'] filename_3 = row['filename_3'] filename_4 = row['filename_4'] filename_5 = row['filename_5'] filename_6 = row['filename_6'] 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 filename_1 != "" and " ": if filepath.__contains__(filename_1): print (file) shutil.copy(filepath, 'C:\\Users\\OVI-CNR\\Desktop\\extracted_images') if filename_2 != "" and " ": if filepath.__contains__(filename_2): print (file) shutil.copy(filepath, 'C:\\Users\\OVI-CNR\\Desktop\\extracted_images') if filename_3 != "" and " ": if filepath.__contains__(filename_3): print (file) shutil.copy(filepath, 'C:\\Users\\OVI-CNR\\Desktop\\extracted_images') if filename_4 != "" and " ": if filepath.__contains__(filename_4): print (file) shutil.copy(filepath, 'C:\\Users\\OVI-CNR\\Desktop\\extracted_images') if filename_5 != "" and " ": if filepath.__contains__(filename_5): print (file) shutil.copy(filepath, 'C:\\Users\\OVI-CNR\\Desktop\\extracted_images') if filename_6 != "" and " ": if filepath.__contains__(filename_6): print (file) shutil.copy(filepath, 'C:\\Users\\OVI-CNR\\Desktop\\extracted_images') #if filepath.__contains__(filename_5):