#!/bin/sh

. /etc/profile
. /etc/flenv

usage(){
	echo "usage1: $0 escape dir [filename...]"
	echo "usage2: $0 restore dir [filename...]"
	exit 1
}

if [ "x$1" = "xescape" ]; then
	suffix1=
	suffix2=.esc
elif [ "x$1" = "xrestore" ]; then
	suffix1=.esc
	suffix2=
else
	usage
fi

shift

targetdir=$1
if [ -z "$1" -o ! -d "$targetdir" ]; then
	usage
fi
shift

pushd $targetdir
for filename in $@
do
	mv -f $filename$suffix1 $filename$suffix2
done
popd
