Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment