4 CONFIG_FILE="config.ini"
6 # copied and modified from http://mark.aufflick.com/blog/2007/11/08/parsing-ini-files-with-sed
7 eval `sed -e 's/[[:space:]]*\=[[:space:]]*/=/g' \
10 -e 's/[[:space:]]*$//' \
11 -e 's/^[[:space:]]*//' \
12 -e "s/^\(.*\)=\([^\"']*\)$/\1=\"\2\"/" \
17 dbprefix=${dbprefix//\//\\\/}
22 echo "TODO: use comma seperate tags for --include=... and/or --exclude=..."
43 # check database version, exit if different from what we expect
44 DBVERSION=`sqlite3 $REMOTEDB 'select data from meta where name="F-Spot Database Version"'`
46 if [ x"$DBVERSION" != "x18" ] ; then
47 echo "The database is from a different F-spot version (database version $DBVERSION) that is not implemented."
48 echo "Check TODO for a newer version or file a bug-report at: TODO"
53 # join tags together in a list of comma seperated quoted strings, so that they can be used in DB queries
54 INCLUDE="'${CL_INCLUDE/,/','}'"
55 EXCLUDE="'${CL_EXCLUDE/,/','}'"
57 if [ "x$INCLUDE" != "x" ] ; then
58 echo "only including pictures with tags: $INCLUDE"
61 if [ "x$EXCLUDE" != "x" ] ; then
62 echo "excluding all pictures with tags: $EXCLUDE"
65 if [ "x$EXCLUDE" == "x" -a "x$INCLUDE" == "x" ] ; then
66 echo "using all pictures from the database"
69 # test if localdb already exist:
71 # see if photo-db is newer? yes: merge them; no: do nothing
78 if [ "x$EXCLUDE" != "x" ] ; then
79 ExcludeTags="insert into rmphotoids select photo_id from photo_tags where tag_id in (select id from tags where name in ($EXCLUDE));"
82 # delete all photo related information that we don't want to keep in case INCLUDE tags were given
83 sqlite3 $LOCALDB <<EOF
84 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)));
88 delete from photos where id in (select * from rmphotoids);
89 delete from photo_tags where photo_id in (select * from rmphotoids);
90 delete from photo_versions where photo_id in (select * from rmphotoids);
92 delete from tags where id not in (select distinct tag_id from photo_tags asc);
93 delete from rolls where id not in (select distinct roll_id from photos asc);
95 drop table rmphotoids;