Renaming photos with date taken using exiftool and nautilus scripts.

exiftool file-management linux photography

This is a short TIL about to rename photo files such that the date is appended to the beginning of the filename. In other words,

_DSC_0420.JPG becomes

2022-12-19-_DSC_0420.JPG

where the date is in year-month-day format.

Why is this needed? Jenny Bryan’s NormConf lightning talk explains file-naming importance in 5 minutes, and Gerrit Vyn’s Bird Photography book renames photo files with the date as a part of his file management.

What I’ve done is create a script that is accessible using a right-click in nautilus. My main source to get started is this SE answer. I’m on Ubuntu.

Create .sh file

Create a .sh file in ~/.local/share/nautilus/scripts. Mine is renameByDate.sh, and its contents are below.

#!/bin/bash

exiftool -fileOrder DateTimeOriginal -recurse -ignoreMinorErrors '-FileName<CreateDate' -d %Y-%m-%d-%f.%%e "$@"

In my version, I keep the original filename in the new filename. Others use counters. I highly recommend testing with a small directory! The syntax to run would be

sh renameByDate.sh directory

Need exiftool? sudo apt install libimage-exiftool-perl should get you there in Ubuntu.

Remember to change permissions

Change the permissions of this file,

 chmod u+x renameByDate.sh

Run from nautilus

On Ubuntu 20.04 LTS, I didn’t have to log out of restart – the script was there. Do to the directory name in nautilus, right click, and in the menu there’s scripts now. You can select the renaming script. Done!

Cavaets

This approach uses exiftool, which assumes that photo files have relevant metadata. Some do not, such as screenshots on my system.

© Amy Tabb 2018 - 2023. All rights reserved. The contents of this site reflect my personal perspectives and not those of any other entity.