This script is pretty much the same as the previous script, but converts everything to monochrome (with the exception of the first page).
It’s a little less cleanly written, and ends up converting the first page twice (it does the whole document in monochrome, then deletes and replaces the first page in color to keep an exhibit label in color), so for many small documents it can be fairly inneficient, though the efficiency of the ghostscript engine, and the ability to run more than one instance at a time more than makes up for it if just a few documents are long.
IFS=$(echo -en "\n\b")
mkdir "To Add"
for a in `ls |grep -i \.pdf` ; do
echo "STARTING $a $IFS $IFS $IFS"
a=`echo $a| sed 's/\(.*\)\..*/\1/g'`
mkdir "To Add/$a"
gs -sDEVICE=tiffg4 -dNOPAUSE -r600x600 -sOutputFile="./To Add/$a/$a%04d.tif" "$b" </dev/null
rm "./To Add/$a/`echo $a`0001.png"
gs -sDEVICE=tiff24nc -sCompression=lzw -r300x300 -dLastPage=1 -dNOPAUSE -sOutputFile="./To Add/$a/$a.png" "$a.tif" </dev/null
mv "$b" PDFs