How To Sort Your Pictures and Videos Quickly
Did you read my post about archiving footage? If you didn't, it's over here, check it out. As a medium-term solution, I ended up picking up a hard drive docking station so I could use a ton of drives I have just sitting around without breaking my wallet. For now, that solution works.
But in the process of cleaning up older files, I decided to revisit my workflow which could use improvement. I try to keep my footage and photos organized by date. But if I do this manually, then sometimes I don't do it right away and then I have to rush to clear my SD cards so I can reuse them. This leads to random folders with titles like "review later" or "up to august 8 2019.
I decided to write a script to help me sort out the files automatically so I could eliminate the human element. But then I thought, someone, must have done this already. There's no way that I am the only one that needs this type of solution
And I was right. After scouring forums and blog posts talking about how to automatically sort files and folders, I found the winning solution.
TL;DR
If you are a little technical, the script is below. It's short and simple. Just adjust the date format, the destination and the source directories and it should just work. But if you are not technical or familiar with running terminal commands, I explain it in detail below.
I found a promising blog post here, by Mike Beach and that in turn sent me to Github to get his script, but at the very end of the Github page, Mike mentioned a tool named ExifTool by Phil Harvey.
He was also gracious enough to add a 1 line, quick script to make ExifTool do exactly what I wanted. Here's the script, I'll break it down in a moment:
exiftool "-Directory<DateTimeOriginal" -d "%Y/%Y-%m-%d" $DIR
Getting the script
If you want to get this working on OSX, I think the easiest way to get it installed is to use Homebrew.
If you don't already have Homebrew, get it installed and then you'll have access to ExifTool and tons of other tools and utilities that come in handy as well, like the amazing youtube-dl script; more on that later.
Once you have Homebrew installed, just run this command on your Terminal to get ExifTool installed:
brew install exiftool
After a few moments, ExifTool will be installed and available in your system.
How to use the script
Now let's break down the script so you know how to use it.
exiftool "-Directory<DateTimeOriginal" -d "%Y/%Y-%m-%d" $DIR
The first word, exiftool
simply calls the utility. You can just type that into your terminal, hit return and it will show you instructions on how to use it.
Next is the "-Directory<DateTimeOriginal"
part this tells it to create a directory using the date and time based on the EXIF data of the photo or video.
The next part is the flag -d. This tells the script that we want to specify the date format we want to use to create the directory. Next, we define what structure of the folders should be by defining the date format: "%Y/%Y-%m-%d"
. If you notice, there are two instances of the year variable, separated by a slash.
This means that a folder with the year will be created, and inside of that, a folder with the year, month and day will be created. Then the files that match will be moved into that folder.
If you wanted to modify this, you just re-arrange the variables any way it suits your needs. I prefer to use this format YYYY-MM-DD so the script is already set to do that.
The very last part, the $DIR is just a placeholder to tell exiftool where the photos and videos you want to sort exist currently. This is my actual script:
exiftool "-Directory<DateTimeOriginal" -d "/Volumes/ScreenFTB/footage/%Y/%Y-%m-%d" ./
The last part that I changed from $DIR
to ./
means I need to be in the same folder as the files I want to sort out. It's also worth noting that I added /Volumes/ScreenFTB/footage/
to the date formatting part, that specifies that I want the folder structure to be created on the drive called "ScreenFTB" under the folder footage.
One caveat
This one line script is amazing. The only issue I found so far is that videos taken with my Samsung Note 9 don't seem to have any EXIF data so it won't work with those files. For those instances where I use my phone to collect footage, I guess I'll have to sort them by hand or will have to find or write a script that uses the file naming structure of the files.
In conclusion
This script will save tons of time in sorting out files and making your workflow a little faster. I'm grateful for open source and Phil Harvey. It seems he's been maintaining this since 2003!