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