Problem: I had 20.000 pictures from the last couple of years laying around in a messy folder structure. The goal was to structure them in folders for each months and year.
Solution: a quick hack with a couple of lines of shell scripting:
Many image format, have embedded meta information in EXIF format, which can be extracted with the identify command. Ie.:
identify -format %[exif:DateTime] IMG_6909.JPG
returns “2015:02:24 12:33:31”. identify is a part of ImageMagick, and works both on jpg files, and also raw-files if you install ufraw-batch.
The year/month was then extracted as group 1 and 2 of a regexp (dddd):(dd):.* and the file was moved into the directory structure. I made sure that there were a sensible default value by appending a default directory name to output from identify, which would then just be passed through, as the regexp didn’t match when the output was empty.
Finally fdupes removed duplicate files, as some images was laying around in multiple copies with different names.