#!/bin/tcsh -f

if ("$1" == '' || "$1" == '-h' || "$1" == '-help') then
	goto USAGE
endif

set Name = $1

	set ComCnt = 0
	foreach junk ($*)
		@ ComCnt ++
	end


set cnt = 2
while ($cnt <= $ComCnt)
   set Name = `echo "$Name" | sed s/$argv[$cnt]'$'// | sed 's/\.$//'`
	@ cnt ++
end

echo $Name

goto ENDALL

USAGE:
	echo "Usage: `basename $0` <Name> <ext1> <ext2> ....."
	echo "example: `basename $0` Hello.HEAD HEAD BRIK"
	echo "returns Hello" 
	echo "`basename $0` Hello.BRIK HEAD BRIK"
	echo "returns Hello"
	echo "`basename $0` Hello.Jon HEAD BRIK"
	echo "returns Hello.Jon"
   echo "`basename $0` Hello.JonA Jon nA"
	echo "returns Hello.Jo"
	echo ""
   echo "Ziad Saad (saadz@mail.nih.gov)"
   echo "LBC/NIMH/ National Institutes of Health, Bethesda Maryland"
   echo ""
	goto ENDALL
ENDALL:
