summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArun Persaud <arun@nubati.net>2012-11-17 15:47:05 -0800
committerArun Persaud <arun@nubati.net>2012-11-17 15:47:05 -0800
commit47f79633cdbe30be9e1aa1b078dec6382ee74456 (patch)
treec0a102fde2e59b397df1e11bbec1f991e10555a6
parentdbb0ee0fb0ac694652e5bb50e0275731d632a567 (diff)
downloadphoto-tags-47f79633cdbe30be9e1aa1b078dec6382ee74456.tar.gz
photo-tags-47f79633cdbe30be9e1aa1b078dec6382ee74456.tar.bz2
photo-tags-47f79633cdbe30be9e1aa1b078dec6382ee74456.zip
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
-rwxr-xr-xf-spot-db-reduce.sh28
1 files changed, 27 insertions, 1 deletions
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 <<EOF
+f-spot-db-reduce.sh <options>
+
+The script uses config.ini for most of it's input data.
+
+Options:
+ --include=<comma separated taglist> include pictures with these tags
+ --exclude=<comma separated taglist> remove pictures with these tags
+ --hide=<comma separated taglist> 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 <<EOF
create temp table rmphotoids as select id from photos where id not in (select photo_id from photo_tags where tag_id in (select id from tags where name in ($INCLUDE)));
$ExcludeTags
+$HideTags
delete from photos where id in (select * from rmphotoids);
delete from photo_tags where photo_id in (select * from rmphotoids);