Just use File::Find
The following code will edit an entire directory tree, so I'd be careful how I used it. Perhaps some testing first? :)
This script accepts two strings as arguments, and then replaces all occurances of $string1 with $string2. For perfect lowercase matches, it will replace with a lowercase $string2, but for all other matches it will replace with uppercase $string2.
Currently, it will just do lowercase for file renames.
use strict;
use warnings;
use autodie;
use File::Find;
die "Usage: $0 From_string To_string\n" if @ARGV != 2;
my ($from, $to) = map lc, @ARGV;
finddepth(sub {
return if $File::Find::dir =~ /.git\b/;
# Inplace Edit of files
if (-f) {
local @ARGV = $_;
local $^I = '.bak';
while (<>) {
s/\Q$from/$to/g;
s/\Q$from/\U$to/ig;
print;
}
#unlink "$_$^I"; # Uncomment if you want to delete backups
}
# Rename File
my $newfile = $_;
if ($newfile =~ s/\Q$from/$to/ig) {
rename $_, $newfile;
}
}, '.');