Goal: Automate file renaming using BASH, to sort file by EXIF.
Sort by Renaming
Rare but happened, designer require to sort artwork,
such as photograph by the date the picture taken.
The idea is using embedded EXIF data.
If we can extract EXIF data,
we can rename files with almost any EXIF field as suffix.
For example using date and time we can rename from this file:
191320.jpg
to this
2020:08:04 19:13:20 191320.jpg
you can automate the task with bash script.
And then, it is the file manager job to display in a sorted fashioned.
Check EXIF
Most file manager can obtain EXIF information.
Either from file properties, or preview or else.
Extract EXIF Using Imagemagick
There are many ways to extract EXIF,
one of them is using imagemagick.
Identify
Extracting EXIF, can be done using imagemagick.
You must install imagemagick first.
Then run this identify command with verbose option.
Filtering Information
Yes, we can filter information using pipe in bash.
For eaxmple using grep to get any line containg Date.
Beware with the capital letter in grep,
or you may end up with the wrong information.
Now we can go further with just getting the first line.
Automate Renaming Using BASH
Test with one file.
Consider to start from simple script.
Name the file as you want such as exif-extract-test.sh.
And do not forget to set the executable with chmod +x.
I’m using bracket box, to check,
if there are any spaces that need to be trimmed.
With the result as below figure:
Prepare The Case
Supposed we have these folder with a few jpg images.
The Final Script
Name the file as you want such as exif-rename-by-datetime.sh.
I assume you can get any bash reference yourself.
Running The Script
Consider run the script
And have a look at the result.
We are done.
Have fun with your photographs.
Good luck with your designs.
I think this is enough for today.
Thank you for reading.