#!/bin/csh

if ( $# < 2 ) then
   echo "usage: MergePostscript.csh <Postscript-files AugerID> "
   exit 1
endif 

set Nargs=$#
set OutputFile="$argv[$#].ps"
@ Nargs=$Nargs - 1
set FileList=""

set counter=1
while ($counter<= $Nargs) 
    set FileList="$FileList $argv[$counter]"
    @ counter ++
end 

gs -q -sDEVICE=pswrite -sOutputFile=$OutputFile -dNOPAUSE -dBATCH $FileList

foreach file ($FileList)
    rm -f $file
end

echo "\nCreated file $OutputFile \n"

exit 0
