- To: Chris Allen <chris.h.allen@xxxxxxxxx>
- Subject: Re: [SLUG] problem in shell script to merge PDF fils
- From: peter@xxxxxxxxxxxxxxxxxx
- Date: Thu, 19 Feb 2009 10:28:29 +1100
- Cc: "slug@xxxxxxxxxxx" <slug@xxxxxxxxxxx>
- User-agent: Wanderlust/2.14.0 (Africa) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (Gojō) APEL/10.7 MULE XEmacs/21.4 (patch 21) (Educational Television) (i486-linux-gnu)
>>>>> "Chris" == Chris Allen <chris.h.allen@xxxxxxxxx> writes:
Chris> I need to merge several sets of PDF files into a single PDF
Chris> file For example want to merge the files
spaces in file names are difficult to handle, especially when you have
multiple levels of quoting.
Chris> To make life easier I created the following shell script
Chris> #bash echo echo $0 echo $1.pdf echo \"$2\"* echo echo gs
Chris> -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=$1.pdf
Chris> \"$2\"* echo gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite
Chris> -sOutputFile=$1.pdf \"$2\"*
That needs to be "$2" withput the backslashes.
I'd actually want to do something like:
#!/bin/sh
output="$1"
shift
gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile="$output" "$@"
and list all the filenames (properly quoted) on the command line to
the script, thus:
pdfmerge outfile.pdf "a .b.c .pdf" "foo bah .pdf"
etc
In general, I'd avoid file names with spaces or tabs in them. There
are too many badly-written scripts in the wild that will do the wrong
thing with them.
Peter C
--
Dr Peter Chubb http://www.gelato.unsw.edu.au peterc AT gelato.unsw.edu.au
http://www.ertos.nicta.com.au ERTOS within National ICT Australia