X-Git-Url: http://git.scottworley.com/picsort/blobdiff_plain/9ac8dac07bfb3f58231b879ffe36f6abe41ed8df..a05e21670fd3fd2d8e0de963a21ec871b6725f52:/pic-mv?ds=sidebyside diff --git a/pic-mv b/pic-mv index 92444da..0309ec0 100755 --- a/pic-mv +++ b/pic-mv @@ -1,6 +1,9 @@ #!/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= @@ -13,11 +16,18 @@ while getopts d:e:r: opt;do 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" +re_escaped_name=$(sed 's/[?+*.]/\\&/g' <<< "$name") + # Find next number -max=$(ls "$destdir" | sed -rn "s/^$name ([0-9]+).jpeg$/\1/p" | sort -n | tail -n1) +max=$(ls "$destdir" | sed -rn "s/^$re_escaped_name ([0-9]+).jpeg$/\1/p" | sort -n | tail -n1) if [[ "$max" ]];then number=$((max + 1)) else