What I want is 103_track.mp3 to turn into 403_track.mp3. What I get is a file named 4$1. Thanks in advance.c:> rename.pl .*\.mp3 1(\d\d.*) 4$1
my $inputMask = $ARGV[0]; my $regexSearch = $ARGV[1]; my $regexReplace= $ARGV[2]; my @files = <*.*>; foreach my $file ( @files ) { if ( $file =~ /$inputMask/ ) { my $oldname = $file; $file =~ s/$regexSearch/$regexReplace/; rename($oldname, $file) or die "$oldname to $file failed: $!"; print "renamed $oldname to $file\n"; } }
In reply to s/// treat rhs as regex by chuckH
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |