#!/usr/local/bin/perl

if (@ARGV == 0) {
	die "usage: rename DIRECTORY PATTERN NEWPATTERN\n";
}

opendir(DIR,"$ARGV[0]");

while ($a = readdir(DIR)) {
   if ($a =~ /$ARGV[1]/) {
#	print $a,"\n";
	$b = $a;
	$b=~s/$ARGV[1]/$ARGV[2]/g;
#	print $b,"\n";
	rename($a, $b);
   }
}