]> git.scottworley.com Git - picsort/blame_incremental - pic-mv
pic-mv tool to do the last few steps
[picsort] / pic-mv
... / ...
CommitLineData
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
27if [[ "$file" == *.NEF ]];then
28 base="${file%.NEF}"
29 if [[ "$rotate" ]];then
30 echo "NEF rotation not yet implemented" >&2
31 exit 1
32 else
33 mv -vi "$exposure/$base.jpeg" "$destdir/$name $number.jpeg"
34 mv -vi "$file" "$destdir/$name $number.NEF"
35 fi
36else
37 if [[ "$rotate" ]];then
38 sed -i "s/^# ROBOTS_INSERT_THINGS_HERE\$/&\n\"$name $number.jpeg\" => $rotate," "$destdir/rotations.php"
39 fi
40 mv -vi "$file" "$destdir/$name $number.jpeg"
41fi