Skip to content

Instantly share code, notes, and snippets.

@projectivemotion
Last active July 31, 2021 20:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save projectivemotion/599219fe885ab9e05819c44570058917 to your computer and use it in GitHub Desktop.
Save projectivemotion/599219fe885ab9e05819c44570058917 to your computer and use it in GitHub Desktop.
Print Shotwell Photo Filenames by Tag
#!/bin/env bash
#
# Author: Amado Martinez - AmadoMartinez.mx
# License: MIT License
# Date: 2016-05-02
#
# Example:
# $ ./shotwell_filenames_by_tag.sh ~/.local/share/shotwell/data/photo.db MyTag
#
if [ $# -lt 2 ] ; then
echo "Usage: path-to/photo.db tagName"
exit
fi
db="$1"
tag="$2"
function sql(){
sqlite3 "$db" "$1"
}
function getPhotos(){
sql "select photo_id_list from TagTable where name='$tag'" | sed 's/,/\n/g' | sed 's/^thumb//'
}
# Leaving room for improvement ;)
for hexid in `getPhotos` ; do
decid=$((0x${hexid}))
sql "select filename from PhotoTable where id=$decid"
done
@btammaster
Copy link

Thank you for posting this! This is exactly what I was looking for. You saved me a bunch of time (and I wasn't familiar with $((0x${hexid})) before).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment