From b10cf2b350adacaf468f701097aec642ab2df7d5 Mon Sep 17 00:00:00 2001 From: Dan Date: Thu, 15 Dec 2022 23:18:42 -0500 Subject: [PATCH] Initial --- main.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 main.py diff --git a/main.py b/main.py new file mode 100644 index 0000000..8fed301 --- /dev/null +++ b/main.py @@ -0,0 +1,33 @@ +import exifread +from datetime import datetime +import os +import shutil + +path = 'F:\\DCIM\\100CANON\\' +photoPath = 'C:\\Users\\ICYN3\\Pictures\\' +count = 0 + +for each in os.listdir(path): + file = path+each + f = open(file, 'rb') + tags = exifread.process_file(f, stop_tag='DateTimeOriginal') + exif = str(tags['EXIF DateTimeOriginal']) + time = datetime.strptime(exif, '%Y:%m:%d %H:%M:%S') + year = photoPath + datetime.strftime(time, '%Y') + '\\' + date = year + datetime.strftime(time, '%Y-%m-%d')+ '\\' + folder = date + if not os.path.exists(year): + os.mkdir(year) + if not os.path.exists(date): + os.mkdir(date) + if not os.path.exists(folder+each): + try: + shutil.copy(file, folder) + except Exception as e: + print(each + ' failed - ' + e) + # print(folder+each) + # print('move') + else: + print('Already Exists') + count = count + 1 +print('Processed ' + str(count) + ' images') \ No newline at end of file