blob: 10a0ebc64709300170ea37d5b53449c70ebae977 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
#!/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
|