]> git.scottworley.com Git - picsort/commitdiff
pic-mv tool to do the last few steps
authorScott Worley <scottworley@scottworley.com>
Sat, 1 Mar 2014 08:23:03 +0000 (00:23 -0800)
committerScott Worley <scottworley@scottworley.com>
Sat, 1 Mar 2014 08:23:03 +0000 (00:23 -0800)
pic-mv [new file with mode: 0755]

diff --git a/pic-mv b/pic-mv
new file mode 100755 (executable)
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