#!/bin/sh
# Thu Sep 21 23:26:22 CEST 2000
# Moves files matched by 'pattern' to sed command

VERBOSE=false

USAGE="\
   usage: `basename $0` [ -s ] [ -V ] [ -h ] \"PATTERN\" \"sed command\"\
   "
USAGELONG="\
usage: `basename $0` \"PATTERN\" \"sed command\"\n
   -h, --help\t display this text and exit succesfully\n
   -s, --show\t only test; show what whould be done\n
   -V, --verbose\t be a bit more verbose\n 
   \n
   modify filenames from files matched by PATTERN with sed command\n
   Be careful, that PATTERN won't be eaten by the shell"

if test $# -lt 2 ; then 
  echo -e $USAGELONG
  exit 1
fi


while test $# -gt 2 ; do
  case "${1}" in
  -h | --help )
    echo -e $USAGELONG 1>&2
    exit 0
  ;;
  -s | --show )
     VIEW=echo
     shift ;;
  -V | --verbose )
     VERBOSE=true
     shift ;;
  *)
     echo $USAGE 1>&2
     exit 1
  ;;
  esac
done

for i in $1; do
  if test $VERBOSE = true; then
    echo mv "$i" $(echo $i|sed "$2")
  fi
  $VIEW mv "$i" $(echo $i|sed "$2")
done

