diff options
Diffstat (limited to 'img2pdf.sh')
-rwxr-xr-x | img2pdf.sh | 26 |
1 files changed, 19 insertions, 7 deletions
@@ -1,18 +1,30 @@ #!/bin/bash -if [ $# -ne 2 ] ; then +ext=$1 +out=$2 + +if [ -z "$ext" ] ; then echo "img2pdf (png,jpg,tiff,...) (output)" exit fi +if [ -z "$out" ] ; then + out=$(basename `pwd`).pdf +fi -for img in *."$1" ; do +for img in $( echo `ls -v | egrep \."$ext"$` ) ; do echo Traitement de "$img" - convert "$img" "${img:0:-4}.pdf" + convert "$img" "${img:0:-$(( 1 + ${#ext})) }.pdf" done; -rm "$2" -gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile="$2" `ls -v | grep .pdf$` +if [ -e "$out" ] ; then + echo "Gestion backup" + set -x + rm "$out" + set +x +fi + +gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile="$out" `ls -v | egrep \.pdf$` -for img in *."$1" ; do - rm "${img:0:-4}.pdf" +for img in *."$ext" ; do + rm "${img:0: $(( -1 + -${#ext} )) }.pdf" done; |