The standard linux rename
command man page says:
rename will rename the specified files by replacing the first occurrence of from in their name by to.
so it's just for simple file renames. This is the standard rename from util-linux, available on all linux systems I am aware of.
I think you are probably trying to use Larry Wall's example perl rename script. If that's what you really want, create this file in your path:
#!/usr/bin/perl
#
# rename script examples from lwall:
# rename 's/\.orig$//' *.orig
# rename 'y/A-Z/a-z/ unless /^Make/' *
# rename '$_ .= ".bad"' *.f
# rename 'print "$_: "; s/foo/bar/ if <stdin> =~ /^y/i' *
$op = shift;
for (@ARGV) {
$was = $_;
eval $op;
die $@ if $@;
rename($was,$_) unless $was eq $_;
}
make it executable with chmod 755 rename
, and call it instead of the system rename. I tested it with your example and it works.