Dropbox-Style Photo Importing

Dropbox-Style Photo Importing

For a long time I’ve used Dropbox for my photo imports. I now have a pretty complicated system for how I store them, but something I liked about Dropbox was that it imported photos with file names like 2016-04-18 14.10.47.jpg. To me this is a much easier way to think about photos than the default serialized version used by the camera, and it hides the ugly file names that differ across screenshots taken on my phone, photos uploaded by my phone, and photos manually imported from my different cameras. Unfortunately the camera upload feature doesn’t work on Ubuntu.

I was able to replicate the tool using a command line utility. Here’s how I did it for anyone in a similar situation and for myself for future reference.

Find the Photos

My current camera is a Sony RX100m3. When I mount the camera I get two directories: PMHOME and 64 GB Volume, which is the size of the SD card I use in it.

Photos are located at: 64 GB Volume/DCIM/100MSDCF. Videos are stored in another directory, and seem to be at: 64 GB Volume/PRIVATE/AVCHD/BDMV/STREAM. When I first started doing this I didn’t think that they would be in different places and I almost lost them. Yikes.

Copy the Photos Locally

Inside Dropbox I organize my photos by year, eg ~/Dropbox/Photos/2016/. Inside this folder I have an additional 2016_uploadStaging directory where I keep things and let them sync before I move them to their long term more managed locations.

Copy the photos and videos to this location.

Rename the Photos

To mimic what Dropbox does, we want to rename the photos by metadata. Thankfully exiv2 is capable of doing just this. It is even smart enough to handle collisions by automatically appending a _1, etc if two photos are taken in the same second.

I like the format 2016-04-21 14.27.15. This is specified to exiv2 by the argument -r'%Y-%m-%d %H.%M.%S'. The command rename tells it to perform renames using this format, and the argument -F tells it not to prompt when renaming files (this will make it painless to resolve collisions). My camera creates files with a DSC prefix, so the last DSC* glob makes sure it only renames files that haven’t yet been renamed, ignoring photos we may already have processed, videos with a different naming convention, etc.

exiv2 -r'%Y-%m-%d %H.%M.%S' -F rename DSC*


exiv2 doesn’t work for videos, so I just rename them by hand. If I ever take more than 1:1000 videos to photos I might have to come up with a better solution.

comments powered by Disqus