rexname
Categories:
#!/usr/bin/perl
# rexname - Larry's filename fixer
#
# Modified by Brian Mathis to add testing and verbose
#
use strict;
use Getopt::Long;

my $usage = <<USAGE;
Usage:
        rexname expr [files]
        rexname --test expr [files]
        rexname --verbose expr [files]

Options:
        --test (-t)
        Don't actually do anything (implies -v)

        --verbose (-v)
        Display output of changes as they are made
USAGE

my($test, $verbose);
GetOptions("test" => \$test, "verbose" => \$verbose);
if($test) { $verbose = 1; }

my $op = shift or die $usage;
chomp(@ARGV = <STDIN>) unless @ARGV;
for (@ARGV) {
        my $was = $_;
        eval $op;
        die $@ if $@;
        print "$was \t-> $_\n" if $verbose;
        rename($was,$_) unless(($was eq $_) || $test);
}