#!/bin/sh
#
# DOCTOR TXT... Convert all .DOC files to .TXT files, in the .desc
#               files as well as in the actual directory.

echo "Converting all .DOC's to .TXTs...."

if [ "` ls | grep '\.doc' | wc -l`" = "      0" ]
   then 
   echo "...except there aren't any."
   exit 0
fi

echo ""

for each in *.doc
    do
    CONVERT=`echo $each | sed 's/\.doc/\.txt/'`
    
    if [ -f $CONVERT ]
       then
       echo "Oops, there's already a $CONVERT. Not changing."
       else
       echo "Renaming $each to $CONVERT..."
       mv $each $CONVERT
       DESCRIPTION=`grep $each .descs | cut -d' ' -f 2-`
       echo "$CONVERT $DESCRIPTION" >>.descs
    fi
    done
