#! /bin/sh
# Interactively rename performances
for i
do
	echo $i
	vpr $i
	if [ "$?" != "0" ] ; then continue; fi
	PN=`vpr -n $i | map 0=3:12 -t | tr ' ' '_'`
	PN=`echo $PN | tr "'"'\&\!\$\|\`\*\"\/\<\>\(\)\{\}\[\]\\' ' '`
	echo -n "New name? "
	while true ; do
		echo -n "(<CR> for <$PN>, '.' to skip) "
		read NAME
		if [ "$NAME" != "." ] ; then
			if [ "$NAME" = "" ] ; then
				NAME=$PN
			fi
			if [ -s P.$NAME ] ; then
				echo -n "P.$NAME exists.  Compare?  <yes> "
				read YESNO
				if [ "$YESNO" = "" ] ; then YESNO=yes ; fi
				expr "$YESNO" : "y*" >/dev/null
				if [ "$?" = "0" ] ; then
					echo "$i vs. P.$NAME"
					vcmp $i P.$NAME
				fi
				echo -n "Replace old P.$NAME? <no>  "
				read YESNO
				expr "$YESNO" : "y*" >/dev/null
				if [ "$?" != "0" ] ; then
					echo -n "new name? "
					PN=${PN}2
					continue
				fi
			fi
			mv $i P.$NAME
		fi
		break
	done

done
