From 195d8ca6073e713f4e1f60f84e77670a901bc567 Mon Sep 17 00:00:00 2001 From: ache Date: Thu, 8 Nov 2018 16:44:00 +0100 Subject: By suffix --- imgs2pdf.sh | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/imgs2pdf.sh b/imgs2pdf.sh index ce645d1..f0bad2c 100755 --- a/imgs2pdf.sh +++ b/imgs2pdf.sh @@ -1,20 +1,42 @@ #!/bin/bash ext=$1 -out=$2 +suffix=$2 +out=$3 -if [ -z "$ext" ] ; then - echo "img2pdf (png,jpg,tiff,...) (output)" +if [ -z "$suffix" ] ; then + echo "Merge multiples images into a single pdf" + echo "img2pdf (png,jpg,tiff,...) (suffix) [output]" + echo "" + echo "Ex :" + echo "img2pdf jpg photo_book vacances_2017.pdf" exit fi + if [ -z "$out" ] ; then - out=$(basename `pwd`).pdf + out=$suffix.pdf fi -for img in $( echo `ls -v | egrep \."$ext"$` ) ; do + +echo "Prise en compte de " $(ls -v | egrep "^$suffix" | egrep "\.$ext\$") + +while : ; do + read -p "Continue (y/n)?" choice + case "$choice" in + y|Y ) break;; + n|N ) exit;; + * ) echo "Invalid input";; + esac +done + + + +echo "$suffix" + +for img in $(ls -v | egrep "^$suffix" | egrep "\.$ext\$") ; do echo Traitement de "$img" img2pdf --output "${img//$ext/pdf}" "$img" -done; +done if [ -e "$out" ] ; then echo "Gestion backup" @@ -27,4 +49,4 @@ gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile="$out" `ls -v | egrep \.p for img in *."$ext" ; do rm "${img//$ext/pdf}" -done; +done -- cgit v1.2.3