diff options
author | Arun Persaud <arun@nubati.net> | 2012-06-03 10:06:08 -0700 |
---|---|---|
committer | Arun Persaud <arun@nubati.net> | 2012-06-03 10:06:08 -0700 |
commit | 22bd56c3686530b61c930e728eaade45ee17d9cc (patch) | |
tree | a6f30e27d48a3c728bcb760ce9284a6a5cdfd71a | |
parent | ee441e7cba2a15b7a617f103b511545f4029a174 (diff) | |
download | photo-tags-22bd56c3686530b61c930e728eaade45ee17d9cc.tar.gz photo-tags-22bd56c3686530b61c930e728eaade45ee17d9cc.tar.bz2 photo-tags-22bd56c3686530b61c930e728eaade45ee17d9cc.zip |
create thumbnails of all pictures at once, at limit option (-l) if we want to only create a certain number at a time
-l option might be useful in case the script will be run on a system where the resources are limited
-rwxr-xr-x | create_thumbnails.sh | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/create_thumbnails.sh b/create_thumbnails.sh index 15cae68..d1be98d 100755 --- a/create_thumbnails.sh +++ b/create_thumbnails.sh @@ -19,15 +19,25 @@ eval `sed -e 's/[[:space:]]*\=[[:space:]]*/=/g' \ LOCALDB=$fspotdb dbprefix=${dbprefix//\//\\\/} +limit=`$NICE sqlite3 $LOCALDB "select count(*) from photos"` + # parse command line -while getopts ":r" opt; do +while getopts ":rl:" opt; do case $opt in r) removemeta=1 ;; + l) + limit=$OPTARG + ;; \?) echo "Invalid option: -$OPTARG" >&2 + exit 1 + ;; + :) + echo "Option -$OPTARG requires an argument." >&2 + exit 1 ;; esac done @@ -56,10 +66,10 @@ done=0 offset=0 FILES="" -while [ $done -lt 100 ] ; do - echo "skipping $offset pics, getting 50 new pics to work on..." +while [ $done -lt $limit ] ; do + echo "skipping $offset pics, getting $limit new pics to work on..." # handle white space in filename correctly - FILES=`$NICE sqlite3 $LOCALDB "select replace(base_uri||'/'||filename,' ','%20') from photos limit $offset,100"` + FILES=`$NICE sqlite3 $LOCALDB "select replace(base_uri||'/'||filename,' ','%20') from photos limit $offset,$limit"` if [ "x$FILES" != "x" ] ; then #found some files, process them @@ -99,6 +109,6 @@ while [ $done -lt 100 ] ; do break; fi - #get ready to get the next 100 - offset=$((offset+50)) + #get ready to get the next photos + offset=$((offset+$limit)) done |