From 2faddfbc13053ecf387a0067ab2ac4094e6155cb Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Sun, 1 Sep 2013 11:47:55 +0400 Subject: [PATCH] an almost full rewrite of process-archive.sh script, now does almost everything but still is slow... (needs more testing) Signed-off-by: Alex A. Naanou --- scripts/process-archive.sh | 177 ++++++++++++++++++++++++++++--------- 1 file changed, 136 insertions(+), 41 deletions(-) diff --git a/scripts/process-archive.sh b/scripts/process-archive.sh index 8d1c4100..e64277b0 100755 --- a/scripts/process-archive.sh +++ b/scripts/process-archive.sh @@ -1,6 +1,67 @@ #!/bin/bash -if [ "$1" ] ; then +# HACK: this is here to avoid using windows find... +PATH=/bin:$PATH + +printhelp(){ + echo Usage: $0 [ARGUMENTS] [ARCHIVE_ROOT] + echo + echo Arguments: + echo -h --help - print this help and exit. + echo --common-previews PATH + echo - build a single preview set at PATH. + echo + echo --skip-archive - skip creating archive structure \(exiftool\). + echo --skip-previews - skip creating previews \(vips\). + echo --skip-cache - skip creating cache \(buildcache\). + echo --skip-all - same as setting all of the above. + echo + echo NOTE: common preview path is relative to ARCHIVE_ROOT. + echo +} + +# process args... +while true ; do + case $1 in + -h|--help) + printhelp + exit + ;; + + --common-previews) + COMMON_PREVIEWS="${2}/preview (RAW)" + shift + shift + ;; + + --skip-archive) + SKIP_ARCHIVE=yes + echo skipping making archive... + shift + ;; + --skip-previews) + SKIP_PREVIEWS=yes + echo skipping making previews... + shift + ;; + --skip-cache) + SKIP_CACHE=yes + echo skipping making cache... + shift + ;; + --skip-all) + SKIP_ARCHIVE=yes + echo skipping making archive... + SKIP_PREVIEWS=yes + echo skipping making previews... + SKIP_CACHE=yes + echo skipping making cache... + shift + ;; + esac +done + +if [ -z "$1" ] ; then ARCHIVE_ROOT="$1" else ARCHIVE_ROOT="." @@ -26,7 +87,6 @@ JSON_NAME="%-:1d/${METADATA_DIR}/%f.json" # XXX need to also copy jpg originals to the preview dir (things that # were shot in jpeg in-camera)... -# XXX do we need to rotate the images using exif data here??? # XXX need to prevent overwriting of unchanged exif data... # when file exists?? # XXX add PSD metadata extraction... @@ -34,12 +94,14 @@ JSON_NAME="%-:1d/${METADATA_DIR}/%f.json" # -srcfile "$PROCESSED_PREVIEW_NAME" -overwrite_original \ # XXX keep file dates... -exiftool -if '$jpgfromraw' -b -jpgfromraw -w "$PREVIEW_NAME" \ - -execute -if '$previewimage' -b -previewimage -w "$PREVIEW_NAME" \ - -execute '-FileModifyDate /dev/null + + touch -c -r "./$IN" "./${OUT}" + + else + echo "File already exists: ${OUT}" fi } - -# XXX use find... +export SIZE COMPRESSION +export -f makepreview cd "./${ARCHIVE_ROOT}" -# XXX this is ugly but it works... -if [[ $ARCHIVE_ROOT == "." ]] ; then - for FROM in */DCIM/hi-res\ \(RAW\)/*jpg ; do - TO="${FROM/hi-res\ /preview }" - # XXX do different-sized previews... - makepreview "$SIZE" "./$FROM" "./$TO" - done - # pre-build cache... - for p in */DCIM/preview\ \(RAW\)/ ; do - if ! [ -e "./$p" ] ; then - continue - fi - buildcache "./$p" - done -else - for FROM in ./DCIM/hi-res\ \(RAW\)/*jpg ; do - TO="${FROM/hi-res\ /preview }" - - # XXX do different-sized previews... - makepreview "$SIZE" "./$FROM" "./$TO" - done - - # pre-build cache... - for p in ./DCIM/preview\ \(RAW\)/ ; do - if ! [ -e "./$p" ] ; then - continue - fi - buildcache "./$p" - done +# make previews... +if [ -z $SKIP_PREVIEWS ] ; then + find . -path '*hi-res (RAW)/*.jpg' -exec bash -c 'makepreview "$SIZE" "{}"' \; fi + +# collect previews to one location... +if ! [ -z $COMMON_PREVIEWS ] ; then + if ! [ -e "./$COMMON_PREVIEWS" ] ; then + mkdir -p "./$COMMON_PREVIEWS" + fi + find . -type d -name 'preview (RAW)' -exec mv "./\{}" "$COMMON_PREVIEWS" \; +fi + + + +# build cache... +if [ -z $SKIP_CACHE ] ; then + find . -type d -name 'preview (RAW)' -exec buildcache "./\{}" \; +fi + + + # vim:set nowrap nospell :