5
Mar

Using exiftool to Create List of Pictures Matching a Keyword/Tag


JPEG Photos with EXIF data, the topic of this post

The exiftool utility is an indispensable tool in the arsenal of picture organization tools and can save you a ton of time when used properly. There are a TON of uses documented in its manual, but there are even more uses outside of that. You just need to be clever. Take the following shell script for example…

This script will call exiftool from the command line or terminal to search through a directory of photos, pick out the ones that match a particular keyword or tag (certainly not limited to these, it can be any attribute stored in exif data), and then save them to a file. The 2> /dev/null portion simply throws away any messages exiftool creates and only leaves you with the goodies in the $RESULT_FILE. Not only does it find the photos that you want with the “favorites” keyword, it also adds the path so you can use the terminal to open them, sort them, or copy them to another location.

#!/bin/sh

PICS_DIR=/home/username/pictures
KEYWORD=favorites
RESULT_FILE=favorite_photos.txt

echo -n "Now, grab all of your photos tagged with "$KEYWORD" in $PICS_DIR..."
(
   exiftool -ext .JPG -fast -p 'source$directory/$filename;destination$directory/$filename; 
   $Keywords' -qq -r -m "$PICS_DIR" | grep -i "$KEYWORD" > $RESULT_FILE
) 2> /dev/null
echo " done"

I have taken this one step further to develop this script (which I’ve appropriately named “picup”) that automatically uploads photos marked with “favorites” to an online gallery powered by ZenPhoto. Pretty clever if I do say so myself.

Feel free to donate if this post prevented any headaches! Another way to show your appreciation is to take a gander at these relative ads that you may be interested in:


There's 5 Comments So Far

Who Linked To This Post?

  1. digiKam, Gwenview, and tagging - openSUSE Forums

Share your thoughts, leave a comment!