Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

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


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




Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://151980]
[Lady_Aleena]: Um, what?
[james28909]: check is is data or hash or array and do tasks then return needed data
[Lady_Aleena]: james28909, you might want to look at the other two on my scratchpad.
[james28909]: after you send to a sub, you can check if it is array or ref ect with ref
[james28909]: check if it is a hash or an array ect with ref in one sub.
[james28909]: like all the subs calling get_data get_array get_ect, you could just use get_data. once you send the data to get_data, check if it is a hash or an array ect. and do functions for each, in one sub
[james28909]: that looks like it would be alot more work than just renaming the sub though lol

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (9)
As of 2017-05-24 04:54 GMT
Find Nodes?
    Voting Booth?