#!/bin/sh # This script shows what the steps for initializing files' tags in the database # are. Performing the same action in a more elegant and flexible way will be # done in the future. database='./ftag_cache/ftag.sqlite3' ftag_bin='./ftag' # Use the development database by default, use the "real" one if any # command-line argument is given if [ $# -ge 1 ] then database="$HOME/.cache/ftag/ftag.sqlite3" ftag_bin='ftag' fi files=$(sqlite3 -list "$database" 'SELECT canonical_name FROM files;') echo "Available tags" "$ftag_bin" tag list for file in $files do echo "Enter the space-separated list of tags to give ${file}" file_id=$(sqlite3 "$database" "SELECT id FROM files where canonical_name = '${file}'") echo "Id is ${file_id}" file_tags=$(sqlite3 -list "$database" "SELECT name FROM (SELECT * FROM file_tags WHERE file = ${file_id}) JOIN tags ON tag = id;") echo "File already has tags ${file_tags}" read tags for tag in $tags do echo "Tag $tag" "$ftag_bin" file tag "$file" "$tag" done done