exifsort --source ~/unsorted/media/files --dest ~/Photos
When you take a picture with your digital camera or smartphone, a time stamp is embedded in the file. Other cool types of info are also embedded, but that’s not in the scope of what I’m covering here.
I wrote a tool in Perl called exifsort. It takes a directory tree full of unorganized photos and movies, maybe dating from many years back, maybe several levels deep, and it organizes all the files into a date-based directory hierarchy exactly like f-spot or shotwell. In fact, you can use it to put disorganized media files right into your f-spot/shotwell library without even opening the software.
But what’s the use case? Why build this tool when these other photo-management programs already import files properly? The answer: because they don’t. Not always. Sometimes they really mess up, or even worse, sometimes you mess up and your photo software then takes that mistake and beats you over the head with a terabyte of your own stupid.
Recently I found myself in just such a situation, where the actual source of disorganization was from within the Shotwell library. The photos had already been imported, but the back-end filesystem storage was in a bit of disarray. This got me thinking, “How can I fix this? How can I repair my library? How can I organize my thousands of out-of-place files back into their proper directories?”
Shotwell couldn’t do it, because it didn’t think anything was wrong. I needed a tool that would take a source directory, recursively dive through it reading the EXIF data from the photos/movies, and finally place the photos into a target date-based directory hierarchy just like Shotwell does on its first import. Such a tool could be very handy.
Enter exifsort. Do I even need to tell you that the first thing I did was go to CPAN, knowing that someone had surely already written an EXIF data parser? Step 2: open vim, insert code. Step 3: execute the new code. Step 4: throw it up on github for others and tell the world!
Now it’s not much. It does work and it does do some nice things like tell you about conflicts and provide md5sums for same-name files. It could become more, if someone asked for features or forked it themselves. You can grab it on github, install the prerequisite modules, and run it right out of the box.