first check-in of feisty meow codebase. many things broken still due to recent
[feisty_meow.git] / scripts / files / prefix_renamer.sh
1 #!/bin/bash
2
3 if [ $# -lt 1 ]; then
4   echo $0: requires at least one argument as the file prefix to remove or replace.
5   echo If there is a second argument, it will be used as the replacement.  Otherwise,
6   echo the replacement string will simply be removed from all matching files in the
7   echo current directory.
8   exit 1
9 fi
10
11 prefix=$1
12 new_prefix=$2
13 for i in $prefix*; do
14   mv $i $(echo $i | sed -e "s/$prefix*\(.*\)/$new_prefix\1/" )
15 done
16