my $dir = 'c:/'; my $from = '.pl'; my $to = '.pl.bak'; while (<$dir*$from>) { my ($old,$new); $old = $new = $_; $new =~ s/$from$/$to/; next if $old eq $new; unless (exist($new)) { rename $old, $new and print "Renamed $old $new\n"; } } sub exist { my $file = shift; if (-e $file) { print "File $file exists, owerwrite (y/n) "; return (<> =~ m/^y/i) ? 0 : 1 } return 0; }
In reply to Renaming Files by tachyon
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |