use dirname instead of string handling
authorfpunktk <git@fpunktk.de>
Sat, 30 Dec 2017 11:26:31 +0000 (12:26 +0100)
committerfpunktk <git@fpunktk.de>
Sat, 30 Dec 2017 11:26:31 +0000 (12:26 +0100)
anondcim

index 027ccc6822823be3931925eb07f0a070fd9c1ab4..feae7667ffaa2845f607ea6f09fa152fb0ca02aa 100755 (executable)
--- a/anondcim
+++ b/anondcim
@@ -73,11 +73,12 @@ do
     #
     if [ "$dst_dir" = "--same--" ]
     then
-        # if the filename contains a "/" then use this dir
-        [ "$fn" != "${fn%/*}" ] && dst="${fn%/*}/" || dst=""
+        # use the directory of the source file
+        dst="$(dirname "$fn")/"
     else
         dst="$dst_dir"
     fi
+    #
     # always use a padded number as destination filename suffix
     dst_jpg="$dst$file_prefix$(echo -n "0000000000$cur" | tail -c ${#total}).jpg"
     while [ -e "$dst_jpg" ] && [ $addend -lt 1000 ]