A script for monochrome tiffs

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.

#!/bin/bash
SAVEIFS=$IFS
IFS=$(echo -en "\n\b")
mkdir "To Add"
mkdir PDFs
for a in `ls  |grep -i \.pdf` ; do
    echo "STARTING $a $IFS $IFS $IFS"
    b=$a
    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
#-r400x400
    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

    done

IFS=$SAVEIFS

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>