Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: file case change

by tachyon (Chancellor)
on Mar 15, 2002 at 14:04 UTC ( #151980=note: print w/ replies, xml ) Need Help??


in reply to file case change

You need something like this:

$path = 'c:/TEST'; opendir DIR, $path or die "Cant open $path, perl says $!\n"; while (my $file = readdir DIR) { next if -d "$path/$file" or -l "$path/$file"; $lc_name = lc $file; rename "$path/$file", "$path/$lc_name" or print STDERR "Can't rena +me $path/$file, perl says $!\n"; }

This avoids 1)lowercasing the whole path (won't exist) and 2) skips dirs and symlinks and lc's all else

Update

Added or print STDERR.... for ChOas ;-)

cheers

tachyon

s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print


Comment on Re: file case change
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://151980]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (9)
As of 2014-07-30 10:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (230 votes), past polls