I wrote a small python script to sort my images into folders named month + year where the image was taken. (I've got just too many from my son and didn't like to sort them by hand at some point). Not more or less. Put into the directory where the images are and run.
#moves images of working directory into folders with their creation month + year
from shutil import move
from os import listdir, makedirs, getcwd
from os.path import isfile, join, exists, isdir
import exifread
import sys
months = {'01' : 'January', '02' : 'February', '03' : 'March', '04' : 'April',
'05' : 'May', '06' : 'June', '07' : 'July', '08' : 'August', '09' : 'September',
'10' : 'October', '11' : 'November', '12' : 'December'}
path_name = getcwd()
files = [ f for f in listdir(path_name) if isfile(join(path_name,f))]
for image in files:
with open(image, "rb") as f:
tags = exifread.process_file(f, stop_tag='EXIF DateTimeOriginal')
datestr = "0"
if "EXIF DateTimeOriginal" in tags:
datestr = str(tags["EXIF DateTimeOriginal"])
elif "Image DateTime" in tags:
datestr = str(tags["Image DateTime"])
if not datestr == "0":
month = months[datestr.split(":")[1]]
year = datestr.split(":")[0]
folder = month + " " + year
if not exists(folder):
makedirs(folder)
if isdir(folder):
move(image, folder)
print "moved", image, "to", folder, "with date", datestr
else:
print >> sys.stderr, folder, "is no directory"
else:
print "no date found for", image