]> git.scottworley.com Git - picsort/blame - pic-mv
'i' to show Info (number, name) for current pic
[picsort] / pic-mv
CommitLineData
7a7a7a75
SW
1#!/bin/bash
2
3destdir=/some/path # Optional: Fill this in here.
4
5exposure=
6rotate=
7while getopts d:e:r: opt;do
8 case $opt in
9 d) destdir=$OPTARG;;
10 e) exposure=$OPTARG;;
11 r) rotate=$OPTARG;;
12 esac
13done
14shift `expr $OPTIND - 1`
15
16file="$1"
17name="$2"
18
19# Find next number
20max=$(ls "$destdir" | sed -rn "s/^$name ([0-9]+).jpeg$/\1/p" | sort -n | tail -n1)
21if [[ "$max" ]];then
22 number=$((max + 1))
23else
24 number=1
25fi
26
7e0b085a
SW
27out="$destdir/$name $number.jpeg"
28
7a7a7a75
SW
29if [[ "$file" == *.NEF ]];then
30 base="${file%.NEF}"
9ac8dac0 31 NEFout="$destdir/$name $number.NEF"
7a7a7a75 32 if [[ "$rotate" ]];then
7e0b085a
SW
33 numeric_exposure=$(dc <<< "2k $exposure 4 / 3.5-p")
34 pics-run-ufraw "$numeric_exposure" "$file" "$out" "$rotate"
7a7a7a75 35 else
7e0b085a 36 mv -vi "$exposure/$base.jpeg" "$out"
7a7a7a75 37 fi
5167ae01 38 touch -r "$file" "$out"
9ac8dac0
SW
39 mv -vi "$file" "$NEFout"
40 chmod 644 "$NEFout"
7a7a7a75
SW
41else
42 if [[ "$rotate" ]];then
4ef7056e 43 sed -i "s/^# ROBOTS_INSERT_THINGS_HERE\$/\"$name $number.jpeg\" => $rotate,\n&/" "$destdir/rotations.php"
7a7a7a75 44 fi
7e0b085a 45 mv -vi "$file" "$out"
7a7a7a75 46fi
9ac8dac0 47chmod 644 "$out"