#!/bin/bash
if [ "$1" == "--help" ]; then
	echo "Execute command followed by up to 9 PDF files to merge."
	echo "This will produce a PDF called \"out.pdf\""
	exit
fi

COUNTER=1
until [ $COUNTER -gt 10 ]; do
	if [ -n "${!COUNTER}" ]; then
		FILES="$FILES ${!COUNTER}"
	fi
	let COUNTER+=1
done

echo "Creating PDF File"

gs -q -sPAPERSIZE=letter -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=out.pdf$FILES

echo "Finished creation of \"out.pdf\""
