Got countless directories after taking portraits with the Google Camera App? Here’s how to batch rename and move the files into a single directory. Readily available as a GitHub Gist.
A Powerful Camera in My Pocket
The difference was noticeable. Really noticeable. Kind of obvious at first (image) sight. While my old phone wasn’t particularly bad when it came to the camera system, the Pixel 3a just was on a different level altogether.
The camera hardware combined with the superb Google Camera App made it a winning combination. Especially at that price point. And not just for me. Several reviews have praised the camera system (whose rear camera is identical to the one found on the excellent Pixel 3) since Google released the Pixel 3a in May of 2019.
I have to admit that, even one year later, I still really like my nifty Pixel 3a. It’s a great compact camera by any standard. In fact, it’s a great camera by many standards. Best of all, the form factor allows me to always have it with me. And the hardware and software combination delivers stunning results when I need them the most.
Organising Photos as Plain Files
Google being Google not only packs its Camera App with great features but, thankfully, also sticks to a sensible standard when it comes to naming the resulting images.
The naming standard used by the Google Camera App is loosely based on the great ISO-8601 date and time standard; hence, logical and lexicographically stable. A typical directory listing excerpt would look like
$ find . | sort ... ./IMG_20200912_102603.jpg ./IMG_20200912_121123.jpg ./IMG_20200912_134612.jpg ...
It’s clearly visible from the file name that the above images were taken on 2020-09-12, with the first one being taken at at 10:26:03, the second one at 12:11:23, and the third one at 13:46:12. Bear in mind that these are local times!
This is great as I prefer to store images organised by date and time taken as plain files on my NAS, thus removing any reliance on image organising software. This works great. Until there is a naming standard for new assets that breaks it.
When Google Gives You Everything
Even though the Google Camera App is packed with features, I tend to stick to a few select (read: familiar) ones. So, it was no surprise that it took me a while until I “discovered” portrait mode.
It does what it says. Produces nice looking portraits. With (artificially added) Bokeh in order to highlight the subject in focus. As there is post-processing involved, the creators of the Google Camera App make both images — the original as well as the post-processed portrait — available to the end user.
And that’s not a bad idea. Except that for portraits, the corresponding two files are organised in a slightly different way as shown in below example directory listing excerpt for a single portrait
$ find . | sort ./IMG_20200912_135702 ./IMG_20200912_135702/00000PORTRAIT_00000_BURST20200912135702027.jpg ./IMG_20200912_135702/00100lrPORTRAIT_00100_BURST20200912135702027_COVER.jpg
Over the past months, I have observed that images related to a single portrait are grouped in a folder that follows the naming convention for non-portrait images. The post-processed portrait is named
*_COVER.jpg whereas the original image inside the folder is lacking that suffix.
A Rule to Rename Portrait Assets
Unfortunately, the naming convention for portrait assets breaks my eventual storage system of plain files in a single directory. But this can be easily bent into shape.
For every portrait directory
IMG_YYYYmmdd_HHMMSS, rename the original image to
IMG_YYYYmmdd_HHMMSS.jpgand the post-processed portrait to
IMG_YYYYmmdd_HHMMSS_PORTRAIT.jpg, then move both images up one level. Do nothing in case there are not exactly two files in the directory.
With the above rule applied to the example portrait assets from the previous section, the resulting directory listing excerpt becomes
$ find . | sort ./IMG_20200912_135702.jpg ./IMG_20200912_135702_PORTRAIT.jpg
We’re back to plain files in a single directory while retaining all images and at the same time reducing complexity! Mild success.
Everything in One Go
When wrapping the above rule with some favourable output formatting for humans, the result is a single Bash script in the following GitHub Gist
So, How do You Rename Portraits?!
While the above Worx for Me!™ when it comes to batch renaming Google Camera App portraits, you may have an alternative or better way.
Think this is all rubbish, incomplete, massively overcomplicated, or simply the wrong tool for the job?! Feel free to leave a comment or contribute to the GitHub Gist or reach out to me on LinkedIn and teach me something new!
As always, prove me wrong and I’ll buy you a pint!