#!/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."