Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://151980]
help
Chatterbox?
[marto]: the wind woke the kids in the early hours of the morning.
[Corion]: marto: Ow! You got hit by the storm that is bringing warm weather to me ...
[1nickt]: marto Good to hear that was the worst of it for you...
[marto]: 1nickt the worst I'm aware of at the moment :P
LanX .♩..♬ ... Another one bites the Sahara dust ...
marto wonders what fresh hell the firefox update has brought, apart from maxing out CPUs

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (9)
As of 2017-10-17 12:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My fridge is mostly full of:

















    Results (230 votes). Check out past polls.

    Notices?