+#!/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