]> git.scottworley.com Git - picsort/commitdiff
Support '?' in destination filenames
authorScott Worley <scottworley@scottworley.com>
Tue, 23 Dec 2014 06:12:37 +0000 (22:12 -0800)
committerScott Worley <scottworley@scottworley.com>
Tue, 23 Dec 2014 06:12:37 +0000 (22:12 -0800)
pic-mv

diff --git a/pic-mv b/pic-mv
index 23da8c3746cf49f1f98444c418a1c8ef4c0e1506..0309ec0393e23910a1ad4b16296f7721b97340d7 100755 (executable)
--- a/pic-mv
+++ b/pic-mv
@@ -24,8 +24,10 @@ 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