aboutsummaryrefslogtreecommitdiff
path: root/img2pdf.sh
diff options
context:
space:
mode:
Diffstat (limited to 'img2pdf.sh')
-rwxr-xr-ximg2pdf.sh26
1 files changed, 19 insertions, 7 deletions
diff --git a/img2pdf.sh b/img2pdf.sh
index 502b218..cdf3f96 100755
--- a/img2pdf.sh
+++ b/img2pdf.sh
@@ -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;