Pass a File to Automator for excuting shell script

I have a few books in PDF format, and they are growing everyday as I am downloading more from internet. I want to split the books in 20 pages range and import the splitted pages into Devonthink. I have a shell script to split the PDF files. I know Hazel can run shell scripts. But, don't want that. I want the script to be executed inside the Automator. The reason is: to create complete workflow for importing into Devonthink using the Automator actions. How can Hazel pass my files to Automator so that the automator will execute the shell script on them and import them into DT?
Do I need a special command, or "$1" supposed to work for a script in the automator?
Her is the script if you want to look at:
I am completely novice; I get the script from other people. Can sb help me please?
Do I need a special command, or "$1" supposed to work for a script in the automator?
Her is the script if you want to look at:
- Code: Select all
echo "Page count: "
ournum=`gs -q -dNODISPLAY -c "("$1") (r) file runpdfbegin pdfpagecount = quit" 2>/dev/null`
declare -i counter;
declare -i counterplus;
counter=1;
while [ $counter -le $ournum ] ; do
echo $counter
newname=`echo $1 | sed -e s/\.pdf//g`
reallynewname=$newname-$counter.pdf
counterplus=$counter+20;
# make the individual pdf page
yes | gs -dBATCH -sOutputFile=$reallynewname -dFirstPage=$counter -dLastPage=$counterplus -sDEVICE=pdfwrite "$1" >& /dev/null
counter=$counterplus
done;
I am completely novice; I get the script from other people. Can sb help me please?