diff options
-rwxr-xr-x | pdfmerge | 10 |
1 files changed, 9 insertions, 1 deletions
@@ -3,9 +3,17 @@ args=$(($# - 1)) +infiles=(${@:1:args}) +outfile=${!#} + if [[ $# = 0 ]] || [[ $args = 0 ]]; then echo "usage: ${0##*/} input.pdf [input2.pdf ..] output.pdf" exit 0 fi -gs -dNOPAUSE -dQUIET -dBATCH -sOutputFile=${!#} -sDEVICE=pdfwrite "${@:1:$args}" +if [[ -e $outfile ]]; then + printf "Error: Output file '%s' already exists!\n" "$outfile" >&2 + exit 1 +fi + +gs -dNOPAUSE -dQUIET -dBATCH -sOutputFile="$outfile" -sDEVICE=pdfwrite "${infiles[@]}" |