develooper Front page | perl.beginners | Postings from February 2002

RE: Chaning case

Thread Previous | Thread Next
Timothy Johnson
February 28, 2002 23:15
RE: Chaning case
Message ID:
The current directory notation in Windows is also ".", but I'd be interested
to see if Windows will let you do it that way, since to the OS "MyDir",
"MYDIR", and "mydir" are all the same name.  If you are using Windows you
might end up having to do it in two steps; one changing the name to a
temporary name, and another changing it to lowercase.

-----Original Message-----
From: Michael Kelly
Sent: 2/28/02 9:58 PM
Subject: Re: Chaning case

On 2/28/02 9:33 PM, Daniel Falkenberg <> wrote:

> G'day All,
> Quick question I want to be able to change all folders in a directory
> lower case?  Does any one know how I could do this using Perl?
> Would I go something like this?
> system('lc *');
> well something like that... :)
> Regards,
> Dan

This seems a bit like a job for a shell script (I remember seeing one
did just that once), but here's a script that changes all the files in
current dir to lowercase:

##### CODE #####

#!/usr/bin/perl -w
use strict;

my @files = readdir(CWD);

foreach my $file (@files){
    my $lcfile = lc($file);
    print "$file -> $lcfile\n";

##### END CODE #####

That should work on a *nix system. (the name passed to opendir() would
":" on a Mac, and I'm-not-sure-what on Windows).

Hope that helps,

To unsubscribe, e-mail:
For additional commands, e-mail:

This email may contain confidential and privileged 
material for the sole use of the intended recipient. 
If you are not the intended recipient, please contact 
the sender and delete all copies.

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About