find_letter_image update.py 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #Cerca i file relativi alle immagini delle lettere DATINI e le copia
  2. #%%
  3. import csv
  4. from fileinput import filename
  5. import os
  6. import os.path
  7. import shutil
  8. #%%
  9. csv_lettere = open('C:\\Users\\OVI-CNR\\Desktop\\Immagini Datini\\datini_associate_images_2.csv')
  10. reader = csv.DictReader(csv_lettere)
  11. for row in reader:
  12. line = []
  13. filename_1 = row['filename_1']
  14. filename_2 = row['filename_2']
  15. filename_3 = row['filename_3']
  16. filename_4 = row['filename_4']
  17. filename_5 = row['filename_5']
  18. filename_6 = row['filename_6']
  19. for subdir, dirs, files in os.walk("Z:\\IMMAGINI DATINI"):
  20. for file in files:
  21. #print os.path.join(subdir, file)
  22. filepath = subdir + os.sep + file
  23. if filename_1 != "" and " ":
  24. if filepath.__contains__(filename_1):
  25. print (file)
  26. shutil.copy(filepath, 'C:\\Users\\OVI-CNR\\Desktop\\extracted_images')
  27. if filename_2 != "" and " ":
  28. if filepath.__contains__(filename_2):
  29. print (file)
  30. shutil.copy(filepath, 'C:\\Users\\OVI-CNR\\Desktop\\extracted_images')
  31. if filename_3 != "" and " ":
  32. if filepath.__contains__(filename_3):
  33. print (file)
  34. shutil.copy(filepath, 'C:\\Users\\OVI-CNR\\Desktop\\extracted_images')
  35. if filename_4 != "" and " ":
  36. if filepath.__contains__(filename_4):
  37. print (file)
  38. shutil.copy(filepath, 'C:\\Users\\OVI-CNR\\Desktop\\extracted_images')
  39. if filename_5 != "" and " ":
  40. if filepath.__contains__(filename_5):
  41. print (file)
  42. shutil.copy(filepath, 'C:\\Users\\OVI-CNR\\Desktop\\extracted_images')
  43. if filename_6 != "" and " ":
  44. if filepath.__contains__(filename_6):
  45. print (file)
  46. shutil.copy(filepath, 'C:\\Users\\OVI-CNR\\Desktop\\extracted_images')
  47. #if filepath.__contains__(filename_5):