Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
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 exploiting the Monastery: (12)
As of 2015-07-31 07:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (275 votes), past polls