diff options
author | ache <ache@ache.one> | 2018-11-08 16:44:00 +0100 |
---|---|---|
committer | ache <ache@ache.one> | 2018-11-08 16:44:00 +0100 |
commit | 195d8ca6073e713f4e1f60f84e77670a901bc567 (patch) | |
tree | 7a666ec3f1b7c368cb8a8b6e57ce7526edfcd7ab | |
parent | Install update (diff) |
By suffix
-rwxr-xr-x | imgs2pdf.sh | 36 |
1 files 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 |