#!/bin/sh
#
#NAME
#  change - change file names
#
#SYNOPSIS
#  change "FromPattern" "ToPattern" File...
#
#DESCRIPTION
#
#  This  uses  sed(1)  to  change  the  names  of  files  that  match
#  FromPattern so that their names match ToPattern instead.
#
#  There  is a better version of this:  The perl "rename" script uses
#  perl patterns, and isn't as liable to going berserk if you give it
#  patterns with special characters.
#  
#  see sed(1) for an explanation of patterns

From="$1"
shift
To="$1"
shift
echo $* \
| tr ' ' '\012' \
| sed \
	-e "/$From/!d" \
	-e "s/$From/$To/" \
	-e 's/.*/mv & &/' \
	-e "s/$To/$From/" \
| sh
