#!/bin/sh
# multiple jpgs to one pdf file
# Author: Hector Llorens
# This file is copyleft, enjoy!
szAnswer=$(zenity --entry --text "Save to:" --entry-text "output.pdf");
filesall=""
while [ $# -gt 0 ]
do
	if [ -f "$1" ];then
		files=`echo "$1" | sed 's/ /\?/g'`
		files=`echo "$files" | sed '/\.\(jpg\|jpeg\)$/!d'`
		filesall="$filesall $files"
	fi
	shift
done
convert -compress jpeg $filesall $szAnswer 2> errorjpg.txt
if [ $? -ne 0 ];then errorm=`cat errorjpg.txt`;zenity --error --text "At least one file must be jpg. Error: $errorm"; fi
rm -rf errorjpg.txt

#count=0
#for arg 
#do
#if[ $count -gt 0 ];then
#argss="$args "
#fi
#argss="$argss$arg"
#count=$(($count + 1))
#done
#echo "convert -compress jpeg \"$argss\" \"output.pdf\" 2>error.txt" > error2.txt
#convert -compress jpeg "$argss" "output.pdf" 2>error.txt


