From 47f79633cdbe30be9e1aa1b078dec6382ee74456 Mon Sep 17 00:00:00 2001 From: Arun Persaud Date: Sat, 17 Nov 2012 15:47:05 -0800 Subject: add option to hide tags, e.g. remove them from the database good for example to hide tags like 'public' that are used in an --include statement for the database --- f-spot-db-reduce.sh | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/f-spot-db-reduce.sh b/f-spot-db-reduce.sh index 436e6b1..831e50e 100755 --- a/f-spot-db-reduce.sh +++ b/f-spot-db-reduce.sh @@ -19,12 +19,23 @@ dbprefix=${dbprefix//\//\\\/} function usage () { - echo "TODO: use comma seperate tags for --include=... and/or --exclude=..." + echo < + +The script uses config.ini for most of it's input data. + +Options: + --include= include pictures with these tags + --exclude= remove pictures with these tags + --hide= remove these tags, but leave pictures +EOF + } # parse command line CL_INCLUDE="" CL_EXCLUDE="" +CL_HIDE="" for i in "$@"; do case $i in @@ -34,6 +45,9 @@ for i in "$@"; do --exclude=*) CL_EXCLUDE=${i#*=} ;; + --hide=*) + CL_HIDE=${i#*=} + ;; -h|--help) usage ;; @@ -53,6 +67,7 @@ fi # join tags together in a list of comma seperated quoted strings, so that they can be used in DB queries INCLUDE="'${CL_INCLUDE/,/','}'" EXCLUDE="'${CL_EXCLUDE/,/','}'" +HIDE="'${CL_HIDE/,/','}'" if [ "x$INCLUDE" != "x" ] ; then echo "only including pictures with tags: $INCLUDE" @@ -62,6 +77,10 @@ if [ "x$EXCLUDE" != "x" ] ; then echo "excluding all pictures with tags: $EXCLUDE" fi +if [ "x$HIDE" != "x" ] ; then + echo "removing tags: $HIDE" +fi + if [ "x$EXCLUDE" == "x" -a "x$INCLUDE" == "x" ] ; then echo "using all pictures from the database" fi @@ -79,11 +98,18 @@ if [ "x$EXCLUDE" != "x" ] ; then ExcludeTags="insert into rmphotoids select photo_id from photo_tags where tag_id in (select id from tags where name in ($EXCLUDE));" fi +HideTags="" +if [ "x$HIDE" != "x" ] ; then + HideTags="delete from photo_tags where tag_id in (select id from tags where name in ($HIDE)); + delete from tags where name in ($HIDE);" +fi + # delete all photo related information that we don't want to keep in case INCLUDE tags were given sqlite3 $LOCALDB <