From d2cd29223d90aa13944ba03c4e0f5173e19c1188 Mon Sep 17 00:00:00 2001 From: Soispha Date: Sat, 25 Nov 2023 16:17:36 +0100 Subject: fix(hm/pkgs/scr/con2pdf): Fix command usage errors --- hm/soispha/pkgs/scripts/apps/con2pdf | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) mode change 100755 => 100644 hm/soispha/pkgs/scripts/apps/con2pdf (limited to 'hm/soispha/pkgs/scripts/apps/con2pdf') diff --git a/hm/soispha/pkgs/scripts/apps/con2pdf b/hm/soispha/pkgs/scripts/apps/con2pdf old mode 100755 new mode 100644 index f5b3623e..23ec0ddd --- a/hm/soispha/pkgs/scripts/apps/con2pdf +++ b/hm/soispha/pkgs/scripts/apps/con2pdf @@ -107,14 +107,13 @@ scan() { counter=0; image_cache="$(mktmp)" msg "Converting images to pdfs..."; - while read -r scanned_image;do + while read -r scanned_image; do + echo "$scanned_image" >> "$image_cache" + : $((counter += 1)) if [ "$counter" = "$number_of_pages" ]; then counter=0; process_images "$image_cache" "$name" "$output_directory" echo "" > "$image_cache" - else - echo "$scanned_image" >> "$image_cache" - : $((counter += 1)) fi done < "$(tmp fd . "$tiff_temp_path" "|" sort -n)" } @@ -124,12 +123,16 @@ process_images() { name="$2"; output_dir="$3"; - set -- "" + set -- while read -r image; do set -- "$@" "$image" done < "$image_cache" - convert "$@" -compress jpeg -quality 100 "$output_dir/${name}_${counter}.pdf" + while [ -e "$output_dir/${name}.pdf" ]; do + name="${name}_$(tr -dc 'A-Za-z0-9!"#$%&'\''()*+,-./:;<=>?@[\]^_`{|}~'