From: Scott Worley Date: Sat, 1 Mar 2014 08:23:03 +0000 (-0800) Subject: pic-mv tool to do the last few steps X-Git-Url: http://git.scottworley.com/picsort/commitdiff_plain/7a7a7a750c91bd80e6c7ae0a564c8914bc48298c?ds=sidebyside pic-mv tool to do the last few steps --- diff --git a/pic-mv b/pic-mv new file mode 100755 index 0000000..2774a69 --- /dev/null +++ b/pic-mv @@ -0,0 +1,41 @@ +#!/bin/bash + +destdir=/some/path # Optional: Fill this in here. + +exposure= +rotate= +while getopts d:e:r: opt;do + case $opt in + d) destdir=$OPTARG;; + e) exposure=$OPTARG;; + r) rotate=$OPTARG;; + esac +done +shift `expr $OPTIND - 1` + +file="$1" +name="$2" + +# Find next number +max=$(ls "$destdir" | sed -rn "s/^$name ([0-9]+).jpeg$/\1/p" | sort -n | tail -n1) +if [[ "$max" ]];then + number=$((max + 1)) +else + number=1 +fi + +if [[ "$file" == *.NEF ]];then + base="${file%.NEF}" + if [[ "$rotate" ]];then + echo "NEF rotation not yet implemented" >&2 + exit 1 + else + mv -vi "$exposure/$base.jpeg" "$destdir/$name $number.jpeg" + mv -vi "$file" "$destdir/$name $number.NEF" + fi +else + if [[ "$rotate" ]];then + sed -i "s/^# ROBOTS_INSERT_THINGS_HERE\$/&\n\"$name $number.jpeg\" => $rotate," "$destdir/rotations.php" + fi + mv -vi "$file" "$destdir/$name $number.jpeg" +fi