PDF to Tiff

!/bin/sh

This script is 'pdf2tif'.
It should run in the background: start it with 'pdf2tif &' from a shell or start it in the background at system boot time.

Replace the two directories below with actual input and output directories and LOGFILE with whichever logfile is desired.

Make sure the script has sufficient permission to read and delete the input files and to write the output files

INDIR=$HOME/pdfdir
OUTDIR=$HOME/tiffdir
LOGFILE=/tmp/pdf2tif.log

while true; do FILE=`ls $INDIR | head -1`
 

The following sleep has a dual purpose. First it prevents the script from consuming large resources. Second it ensures that the input file is completely written before we attempt to read it. If input files are very large or if input files are received over a slow network the sleep should be increased appropriately.

sleep 5
if [ X$FILE != X ]; then
ecconv -exp tif \
-resolution 300 \
$INDIR/$FILE $OUTDIR/${FILE%.pdf}.tif
if [ $? -ne 0 ]; then
echo "Conversion of $FILE failed" >> $LOGFILE
fi
rm $INDIR/$FILE
fi
done