Initial
This commit is contained in:
33
main.py
Normal file
33
main.py
Normal 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')
|
||||||
Reference in New Issue
Block a user