#!/bin/sh
# $Id: extend,v 1.2 2007/10/21 02:22:11 grog Exp $
# Append an ending indicating their file type to specified file names.
#
# If the file doesn't end with a period, first add one.
#
# Formerly most of the extend target in Makefile.  The Makefile still
# decides which files to change.
#
for i in $*; do if [ -f $i ]; then 
  base=`basename $i .`;
  file $i | grep JPEG >/dev/null; 
    if [ $? -eq 0 ]; then  
      mv $i $base.jpeg; 
            else 
      file $i | grep GIF >/dev/null; 
      if [ $? -eq 0 ]; then  
        mv $i $base.gif; 
      else 
        file $i | grep PNG >/dev/null; 
	if [ $? -eq 0 ]; then  
	  mv $i $base.png; 
	fi 
      fi 
    fi 
  fi 
done
