"Fossies" - the Fresh Open Source Software Archive

Member "darktable-2.6.3/tools/purge_unused_tags.sh" (20 Oct 2019, 927 Bytes) of package /linux/misc/darktable-2.6.3.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the last Fossies "Diffs" side-by-side code changes report for "purge_unused_tags.sh": 2.6.3_vs_3.0.0.rc0.

    1 #!/bin/sh
    2 
    3 #
    4 # Usage: purge_unused_tags [-p]
    5 #        -p  do the purge, otherwise only display unused tags
    6 #
    7 
    8 LIBDB=$HOME/.config/darktable/library.db
    9 DATADB=$HOME/.config/darktable/data.db
   10 
   11 # tags not used
   12 Q1C="
   13 ATTACH DATABASE \"$LIBDB\" as lib;
   14 ATTACH DATABASE \"$DATADB\" as data;
   15 SELECT name FROM data.tags WHERE id NOT IN (SELECT tagid FROM tagged_images);
   16 "
   17 
   18 Q1="
   19 ATTACH DATABASE \"$LIBDB\" as lib;
   20 ATTACH DATABASE \"$DATADB\" as data;
   21 DELETE FROM data.tags WHERE id NOT IN (SELECT tagid FROM tagged_images);
   22 "
   23 
   24 if [ ! -f "$LIBDB" ]; then
   25     echo missing \""$LIBDB"\" file
   26     exit 1
   27 fi
   28 
   29 if [ ! -f "$DATADB" ]; then
   30     echo missing \""$DATADB"\" file
   31     exit 1
   32 fi
   33 
   34 if [ "$1" = "-p" ]; then
   35     echo Purging tags...
   36     echo "$Q1C" | sqlite3
   37     echo "$Q1" | sqlite3
   38 else
   39     echo The following tags are not used:
   40     echo "$Q1C" | sqlite3
   41     echo
   42     echo to really purge from the database call:
   43     echo "$0" -p
   44 fi