#!/bin/sh

fixenc () {
        # Fix enc figures
        TMPFILE=/tmp/$$

        COUNT=`/bin/grep \^FILENAME $1|/bin/wc -l|/bin/awk '{print \$1}'|/bin/tr -d " "`

        /bin/rm -f ${TMPFILE}
        echo $COUNT > ${TMPFILE}
        /bin/tail +2l $1 >> ${TMPFILE}
        /bin/cp ${TMPFILE} $1
	rm ${TMPFILE}
}


TMPFILE=/tmp/$$

while read dest
	do
	if [ -f $dest ] ; then 
		cat  $dest | sed -e "s/POSTSCRIPT ISOLatinGreekEncoding//" -e "s/X11 iso8859-7//" -e "s/FILENAME ISOLatinGreek.enc//" -e "/^$/d" >  $TMPFILE
		cp $TMPFILE $dest 
		rm $TMPFILE
		fixenc $dest
	fi
done

exit 0
