in reply to Renaming Files
a more general/recursive approach in a oneliner may be: find2perl . -depth -eval 'my $o = $_; s/\.pl$/$&.bak/ and -e or rename $o, $_' | perl -w
... or a 'rewriting' or your code:
#!/usr/bin/perl -w use strict; use File::Find; my ($dir, $in, $out) = @ARGV; File::Find::finddepth( { wanted => sub { my $o = $_; s/$in/$out/ or return; -e or rename $o, $_; } }, $dir );
heh, this latter version suffers ofc of limitation such as:
./kk.pl . '\.pl$' '$&.bak' ... which will not result in renaming 'foo.pl' to 'foo.pl.bak' but to 'foo$&.bak' :)
idea: do an engine to make possible specification of any 'substitution' pattern from the command line ;-)
--
AltBlue.
|
|---|