#!/bin/sh

# converts DOS 8.3 TFMX-filenames back to Amiga format
# (C) 2000 by David Banz <neo@sakura-audio.cx>
# the GPL applies (see file ../COPYING)

if [ "$1" != "go" ]; then
	echo -e ""
	echo `basename $0` "renames all file-pairs with extention .TFX/.SAM"
	echo "and .tfx/.sam back to the Amiga format (prefix mdat./smpl.)."
	echo "example: foo.tfx and foo.sam become mdat.foo and smpl.foo"
	echo -e ""
	echo "USAGE: enter the directory where the files to be renamed reside,"
	echo "and enter: "`basename $0` go
	echo -e ""
	echo "WARNING! be sure to read README_NOW before using this program!"
	exit
fi

echo  "Renaming all 8.3 TFMX-filenames in the current directory (if there are any)..."

for file in *.[t][f][x]
do {
	if [ $file != "*.[t][f][x]" ]; then
		tfxname=$file
		base=`basename $tfxname .tfx`
		samname=$base.sam
		mv $tfxname mdat.$base
		mv $samname smpl.$base
	fi
} done

for file in *.[T][F][X]
do {
	if [ $file != "*.[T][F][X]" ]; then
		tfxname=$file
		base=`basename $tfxname .TFX`
		samname=$base.SAM
		mv $tfxname mdat.$base
		mv $samname smpl.$base
	fi
} done

echo "...done!"
