Back then, I only used Ubuntu and its default photo manager Shotwell.It was pretty handy, but images of my travels were mixed with my casual smartphone pictures. The worst part was the fact that all my pictures were stored on a single folder per date. Then, I started to used Mac with its integrated tool Photos. Like Shotwell, the software is great, especially if you have Apple devices but everything is stored under one giant photoslibrary archive.
Based on all these observations, I started to look for a simple and universal way to sort all my previous and future pictures.
The solution should:
In order to achieve that, I used a ExifTool which is a “platform-independent Perl library plus a command-line application for reading, writing and editing meta information in a wide variety of files”.
To sort my pictures, I am using the following metadata:
See ExifTool page documentation
Tag events
Firstly, I wanted to highlight specific events such as a trip abroad and at the
same time be sure that my sorting was reproducible. To do that, I had to add a metadata information at the photo level.
When you look at the metadata stored in Exchangeable image file format (Exif) there are tens of attributes. By default the UserComment field is not filled, therefore I used this attribute to store my event:
You can write/overwrite the UserComment field via exiftool. By convenience I have incorporated that into a bash script:
#!/bin/bash
## PATH TO MY IMAGES DIRECTORY ##
DEFAULTIMPORTED=/tmp/Images/0_Imported/ #Images to be imported
## USER COMMENT AS A PARAMETER#
TRAVEL=$1
## METADATA WRITING ##
if [ $# -eq 1 ]; then
IMPORTED=$DEFAULTIMPORTED
exiftool -UserComment=$TRAVEL $IMPORTED -overwrite_original
elif [ $# -eq 2 ]; then
IMPORTED=$2
exiftool -UserComment=$TRAVEL $IMPORTED -overwrite_original
else
echo "USAGE: sh tagImportedImages.sh USERCOMMENT [DIRECTORY]"
fi
You can verify the UserComment field as follow:
Sort
Once all specific events are filled at the photo level, I can sort all my images using Exiftool again.
I have decided to use the following logic, but feel free to change it to your convenience:
Here is the script corresponding to the rules above:
#!/bin/bash
## PATH TO MY IMAGES DIRECTORY ##
IMPORTED=/tmp/Images/0_Imported/ #Images to be imported
GALLERY=/tmp/Images/1_Gallery/ #Gallery folder
## SORTING IMAGE COMMAND ##
exiftool -d $GALLERY"%Y/" -r $IMPORTED \
'-Directory<${FileModifyDate}IMAGES' \
'-Directory<${CreateDate}${FileType}' \
'-Directory<${datetimeoriginal}${make}-${model;}_ALL' \
'-Directory<${datetimeoriginal}${make}-${model;}_${UserComment}'
## DELETE REMANING EMPTY FOLDERS ##
find $IMPORTED -type d -empty -delete -mindepth 1
Exiftoll command details:
The script presented above will sort all the images in the IMPORTED folder
and move them to the GALLERY folder. If you try to import images already
present in the GALLERY, they will stay in the IMPORTED folder. This means that all remaining images in GALLERY are duplicates based on the UserComment, and camera, and date and filename.
With the option -o you can sort all the images in the IMPORTED folder and copy them to the GALLERY folder.
Exiftool offers the possibility to consistently sort all my pictures coming from several devices on all the platforms. The tool is also very flexible
and quick. It took 20 minutes to sort 50 GB of photos. Now, I can view
all my photos directly in the default file manager or via gallery
softwares that are reusing the folder structure such as gThumb or Luminar.
(Featured Image by Vladyslav Dukhin from Pexels)