This commit is contained in:
Dan
2022-12-15 23:18:42 -05:00
commit b10cf2b350

33
main.py Normal file
View File

@@ -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')