tiff to pdf

#!/bin/bash
# this file converts tif image to pdf file in present directory and all subdirectoris.
start_time=$(date +%s)

find . -type f -iname "*.tif*" | while read tif; do
 pdf=`echo $tif |sed 's/\(.*\)\..*/\1/'`
 if [[ ! -f "$pdf.pdf" ]];
 then
 tiff2pdf -o "$pdf.pdf" "$tif"
 else
   tstamp=`date +%N`
   pdf="$pdf-n$tstamp"
   if [[ ! -f "$pdf.pdf" ]];
   then
   tiff2pdf -o "$pdf.pdf" "$tif"
   else 
   tstamp=`date +%S`
   pdf="$pdf-n$tstamp"
   tiff2pdf -o "$pdf.pdf" "$tif"
   fi
fi
done
finish_time=$(date +%s)
echo done
echo "Time duration: $((finish_time - start_time)) secs."

Leave a Reply

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

*

* Copy This Password *

* Type Or Paste Password Here *

5,178 Spam Comments Blocked so far by Spam Free Wordpress

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=""> <s> <strike> <strong>