function pdfpextr -a pStart pEnd filename # this function uses 3 arguments: # $1 is the first page of the range to extract # $2 is the last page of the range to extract # $3 is the input file # output file will be named "inputfile_pXX-pYY.pdf" set -l fileOut (string split -r -m1 . $filename)[1]_p{$pStart}-p{$pEnd}.pdf printf $fileOut gs -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -dSAFER \ -dFirstPage=$pStart \ -dLastPage=$pEnd \ -sOutputFile=$fileOut \ "$filename" end