]> git.scottworley.com Git - picsort/blobdiff - pic-mv
Don't re-download or re-rename-to-date seen files
[picsort] / pic-mv
diff --git a/pic-mv b/pic-mv
index 2774a6928fb23674c8c9c2774991231ce2caf715..23da8c3746cf49f1f98444c418a1c8ef4c0e1506 100755 (executable)
--- a/pic-mv
+++ b/pic-mv
@@ -1,6 +1,9 @@
 #!/bin/bash
 
 #!/bin/bash
 
-destdir=/some/path  # Optional: Fill this in here.
+destdir=
+if [[ -e .default-pic-mv-destdir ]];then
+  destdir=$( < .default-pic-mv-destdir )
+fi
 
 exposure=
 rotate=
 
 exposure=
 rotate=
@@ -13,6 +16,11 @@ while getopts d:e:r: opt;do
 done
 shift `expr $OPTIND - 1`
 
 done
 shift `expr $OPTIND - 1`
 
+if [[ -z "$destdir" ]];then
+  echo "Please specify a destdir with -d or .default-pic-mv-destdir" >&2
+  exit 1
+fi
+
 file="$1"
 name="$2"
 
 file="$1"
 name="$2"
 
@@ -24,18 +32,24 @@ else
   number=1
 fi
 
   number=1
 fi
 
+out="$destdir/$name $number.jpeg"
+
 if [[ "$file" == *.NEF ]];then
   base="${file%.NEF}"
 if [[ "$file" == *.NEF ]];then
   base="${file%.NEF}"
+  NEFout="$destdir/$name $number.NEF"
   if [[ "$rotate" ]];then
   if [[ "$rotate" ]];then
-    echo "NEF rotation not yet implemented" >&2
-    exit 1
+    numeric_exposure=$(dc <<< "2k $exposure 4 / 3.5-p")
+    pics-run-ufraw "$numeric_exposure" "$file" "$out" "$rotate"
   else
   else
-    mv -vi "$exposure/$base.jpeg" "$destdir/$name $number.jpeg"
-    mv -vi "$file" "$destdir/$name $number.NEF"
+    mv -vi "$exposure/$base.jpeg" "$out"
   fi
   fi
+  touch -r "$file" "$out"
+  mv -vi "$file" "$NEFout"
+  chmod 644 "$NEFout"
 else
   if [[ "$rotate" ]];then
 else
   if [[ "$rotate" ]];then
-    sed -i "s/^# ROBOTS_INSERT_THINGS_HERE\$/&\n\"$name $number.jpeg\" => $rotate," "$destdir/rotations.php"
+    sed -i "s/^# ROBOTS_INSERT_THINGS_HERE\$/\"$name $number.jpeg\" => $rotate,\n&/" "$destdir/rotations.php"
   fi
   fi
-  mv -vi "$file" "$destdir/$name $number.jpeg"
+  mv -vi "$file" "$out"
 fi
 fi
+chmod 644 "$out"