diff --git a/ui (gen4)/archive/README b/ui (gen4)/archive/README new file mode 100644 index 00000000..095c9391 --- /dev/null +++ b/ui (gen4)/archive/README @@ -0,0 +1 @@ +This is the archive template directory, do not edit this. diff --git a/ui (gen4)/archive/media/img/my/work/process-archive.sh b/ui (gen4)/archive/media/img/my/work/process-archive.sh new file mode 100755 index 00000000..2f8fa99e --- /dev/null +++ b/ui (gen4)/archive/media/img/my/work/process-archive.sh @@ -0,0 +1,272 @@ +#!/bin/bash + +# TODO make this runnable from anywhere... +# - prepend paths with './' only if local/relative + +# HACK: this is here to avoid using windows find... +PATH=/bin:$PATH + +printhelp(){ + echo "Usage: `basename $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 " -c - build a single common path at ARCHIVE_ROOT;" + echo " this is a shorthand for: --common-path '.'." + echo + echo " --skip-archive - skip creating archive structure (use: exiftool)." + echo " --skip-previews - skip creating previews (use: vips)." + echo " --skip-cache - skip creating cache (use: buildcache)." + echo " --skip-all - same as setting all of the above." + echo + echo "NOTE: common preview path is relative to ARCHIVE_ROOT." + echo "NOTE: if no arguments are passed then this will process all directories" + echo " in current location." + echo +} + +# process args... +while true ; do + case $1 in + -h|--help) + printhelp + exit + ;; + + -c) + COMMON_PREVIEWS="." + shift + ;; + --common-previews) + COMMON_PREVIEWS="${2}" + 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 + ;; + *) + break + ;; + esac +done + +if [ -z "$1" ] ; then + ARCHIVE_ROOT="." +else + ARCHIVE_ROOT="$1" +fi + +echo "Doing: \"$ARCHIVE_ROOT\"" + + +METADATA_DIR="metadata" +RAW_PREVIEW_DIR="hi-res (RAW)" +PROCESSED_PREVIEW_DIR="preview" + +PROCESSED_PREVIEW_NAME="%-:1d/${PROCESSED_PREVIEW_DIR}/%f.jpg" +PREVIEW_NAME="%-:1d/${RAW_PREVIEW_DIR}/%f.jpg" +JSON_NAME="%-:1d/${METADATA_DIR}/%f.json" + + +# TODO do a version of this using exiv2... +# - to be more flexible... +# - check speed... +# - give the user more options... +# TODO use dcraw to extract/generate previews if we could not get any +# via exiftool +# dcraw -e $RAW +# - try and extract a preview +# - creates a file: $RAW-thumb.jpg +# dcraw -c $RAW | pnmtojpeg -quality=90 > $JPG +# - process raw and convert to jpeg (slow) + +# XXX need to also copy jpg originals to the preview dir (things that +# were shot in jpeg in-camera)... +# XXX need to prevent overwriting of unchanged exif data... +# when file exists?? +# XXX add PSD metadata extraction... +# -execute '-FileModifyDate $W) s = $H else s = $W ; s / $SIZE" | bc -l) + + # NOTE: bash does not do float comparisons so we cheat again ;) + TOO_SMALL=$(echo "if($FACTOR <= 1) s = 1 else s = 0 ; s" | bc -l) + + # the input is smaller than target size, copy as-is... + if [[ $TOO_SMALL == 1 ]] ; then + echo "$IN: Too small, copying as-is..." + + cp "./$IN" "./$OUT" + + # shrink... + else + echo "($FACTOR): ${OUT}:${COMPRESSION}" + + vips im_shrink "./$IN" "./${OUT}:${COMPRESSION}" $FACTOR $FACTOR 2> /dev/null + fi + + touch -c -r "./$IN" "./${OUT}" + + else + echo "File already exists: ${OUT}" + fi +} + +export SIZE COMPRESSION +export -f makepreview + +cd "./${ARCHIVE_ROOT}" + + + +# make previews... +if [ -z $SKIP_PREVIEWS ] ; then + + #export TOTAL=$(find . -type d -name 'hi-res (RAW)' -exec ls "{}" \; | wc -l) + # XXX do not know how to pass and modify a var... + #export CUR=1 + #export TOTAL=`find . -path '*hi-res (RAW)/*.jpg' | wc -l` + + find . -path '*hi-res (RAW)/*.jpg' -exec bash -c 'makepreview "$SIZE" "{}"' \; +fi + + + +# collect previews to one location... +# XXX test!!! +if ! [ -z "$COMMON_PREVIEWS" ] ; then + if ! [ -e "./$COMMON_PREVIEWS" ] ; then + mkdir -p "./$COMMON_PREVIEWS" + fi + #if [ -z $TOTAL ] ; then + # export TOTAL=`find . -path '*hi-res (RAW)/*.jpg' | wc -l` + #fi + find . -type d \ + -name 'preview (RAW)' \ + -print \ + -exec cp -rl "{}" "./$COMMON_PREVIEWS" \; + #-exec rm -rf "./$d" +fi + + + +# build cache... +if [ -z $SKIP_CACHE ] ; then + #if [ -z $TOTAL ] ; then + # export TOTAL=`find . -path '*hi-res (RAW)/*.jpg' | wc -l` + #fi + if ! [ -z "$COMMON_PREVIEWS" ] && [ -e "./$COMMON_PREVIEWS/preview (RAW)" ] ; then + buildcache "./$COMMON_PREVIEWS/preview (RAW)" + else + find . -type d -name 'preview (RAW)' -exec buildcache "{}" \; + fi +fi + + + +# vim:set nowrap nospell : diff --git a/ui (gen4)/archive/media/img/my/work/sync-flash.sh b/ui (gen4)/archive/media/img/my/work/sync-flash.sh new file mode 100755 index 00000000..83ad94ae --- /dev/null +++ b/ui (gen4)/archive/media/img/my/work/sync-flash.sh @@ -0,0 +1,163 @@ +#!/bin/bash + +DATE=`date +%Y%m%d` +COUNT=1 +TITLE="" + +# base mount dir... +# systems with /mnt +if [ -d /mnt ] ; then + BASE=/mnt + +# raw Cygwin +elif [ -d /cygdrive ] ; then + BASE=/cygdrive + +# OSX +elif [ -d /Volumes ] ; then + BASE=/Volumes +fi + + +while true ; do + case "$1" in + -h|-help|--help) + echo "usage: `basename $0` FLAGS DRIVE [TITLE]" + echo + echo " -h|-help print this message and exit." + echo " -m|-multi single base, multiple sub dirs" + echo " for multiple flash cards in a" + echo " single shoot." + echo " -l|-last last flash card in set, run" + echo " process-archive.sh after copying." + echo " -b|-base the base dir to look for drives in" + echo " default: $BASE" + echo + exit + ;; + + -i|--interactive) + INTERACTIVE=1 + shift + ;; + -m|-multi|--multi) + MULTI=1 + shift + ;; + -l|-last|--last) + LAST=1 + shift + ;; + -b|-base|--base) + BASE=1 + shift + ;; + *) + break + ;; + esac +done + +if ! [ -z "$2" ] ; then + TITLE=" - $2" +fi + +DRIVE=${1} + +while true ; do + if [[ $INTERACTIVE || ! $DRIVE ]] ; then + INTERACTIVE=1 + echo "Select/toggle an option:" + echo "0) Multi flash card mode is `[[ $MULTI ]] && echo "on" || echo "off"`" + echo "1) Directoy description is: \"$TITLE\"." + if [[ ! $DRIVE ]] ; then + echo "a-z|name) type a drive letter or mount name in $BASE and start." + else + echo "a-z|name) type a drive letter or mount name in $BASE and start." + echo "Enter) copy drive ${DRIVE}" + fi + echo "2) build." + echo "3) quit." + read -p ": " RES + + case $RES in + # toggle multi mode... + 0) + MULTI=`[[ ! $MULTI ]] && echo 1 || echo ""` + continue + ;; + 1) + read -p "new description: " TITLE + TITLE=" - $TITLE" + continue + ;; + # continue with same drive or ask again... + "") + if [[ ! $DRIVE ]] ; then + echo "ERR: need a drive to copy from, no defaults." + echo + continue + fi + DRIVE=$DRIVE + ;; + 2) + LAST=1 + break + ;; + + 3) + exit + ;; + + # new drive letter... + *) + DRIVE=$RES + ;; + esac + fi + + # XXX do a real three digit count... + # single flash card... + if [ -z $MULTI ] ; then + DIR="./- ${DATE}.00${COUNT}${TITLE}/" + while [ -e "$DIR" ] ; do + COUNT=$((COUNT+1)) + DIR="./- ${DATE}.00${COUNT}${TITLE}/" + done + BASE_DIR=$DIR + + # multiple flash cards shoot... + else + BASE_DIR="./- ${DATE}${TITLE}/" + DIR="${BASE_DIR}/${DATE}.00${COUNT}/" + while [ -e "$DIR" ] ; do + COUNT=$((COUNT+1)) + DIR="${BASE_DIR}/${DATE}.00${COUNT}/" + done + fi + + + mkdir -vp "$DIR" + + echo "Copying files from $1..." + cp -Rpfv ${BASE}/${DRIVE}/* "$DIR" + echo "Copying files: done." + + + # exit interactive mode... + if [[ ! $MULTI || ! $INTERACTIVE || $LAST ]] ; then + break + fi +done + +if [[ $LAST ]] ; then + COMMON_FLAG=-c +fi + +if [[ ! $MULTI || $LAST ]] ; then + echo "Building archive..." + ./process-archive.sh $COMMON_FLAG "$BASE_DIR" + echo "Building archive: done." +fi + + diff --git a/ui (gen4)/archive/media/img/my/work/update-exif.sh b/ui (gen4)/archive/media/img/my/work/update-exif.sh new file mode 100755 index 00000000..9a34e68a --- /dev/null +++ b/ui (gen4)/archive/media/img/my/work/update-exif.sh @@ -0,0 +1,44 @@ +#!/bin/bash + +DIR=`pwd` + + +exifup(){ + PREVIEW_DIR=$1 + if [ -e "$PREVIEW_DIR" ] ; then + echo doing: `pwd` + exiv2 ex *.psd + mv *.exv "$PREVIEW_DIR" + cd "$PREVIEW_DIR" + exiv2 -k in *.jpg + rm -f *.exv + cd .. + fi + true +} + +if [[ $1 != "" ]] ; then + if ! [ -d "$1" ] ; then + echo "\"$1\": is not a directory." + exit 1 + fi + if [ -e "$1/DCIM/preview/" ] ; then + cd "$1/DCIM/" + else + cd "$1" + fi + exifup ./preview/ + exifup ./hi-res/ + cd "$DIR" +else + for d in */DCIM/ ; do + if [ -e "$1/DCIM/preview/" ] ; then + cd "$d" + else + cd "$d/../" + fi + exifup ./preview/ + exifup ./hi-res/ + cd "$DIR" + done +fi diff --git a/ui (gen4)/archive/media/tree.sh b/ui (gen4)/archive/media/tree.sh new file mode 100755 index 00000000..180c5e20 --- /dev/null +++ b/ui (gen4)/archive/media/tree.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +TREE=`date +"%Y%m%d-%H%M"` + + +if ! [ -d ./.tree ] ; then + echo creating .tree directory... + mkdir .tree + attrib +H .tree +fi + +echo building current tree... +tree -a -s --sort name -I '.tree*' > ./.tree/$TREE + +echo setting LAST/CURRENT states... +[ -e ./.tree/CURRENT ] && cp ./.tree/CURRENT ./.tree/LAST +cp ./.tree/$TREE ./.tree/CURRENT + +if [ -e ./.tree/LAST ] ; then + echo diff... + # XXX + diff ./.tree/LAST ./.tree/CURRENT +fi + +