#! /bin/tcsh
#  pdfselect
#  Claus Gerhardt
#
# Enter a list containing pages or page ranges x:y a:b z filename
# The last item in the list has to be the filename without suffix .pdf
# The resulting selections will be named filename-i.pdf, where 1<=i< length of list


set path= ($path  /usr/local/bin  /Library/TeX/texbin /usr/texbin)

set filename="$argv[$#]"

@ i=1 
 while ($#>1) 
@ j=$#
 texexec  --pdfselect --batch  --silent --selection="$1" --result="$filename-$i.pdf" "$filename.pdf" && rm -f "$filename-$i.tui" && rm -f "$filename-$i.tmp"   && rm -f "texexec.tex" && rm -f "texexec.tmp" && rm -f "texexec.tui" && rm -f "mprun.mp" rm -f "mpgraph.mp" && rm -f "$filename-$i.log"
@ i++ 
 shift
end
