this *should* work:.

__ START __
my $path = qq~/home/phisher/documents~; # set this to your path
opendir(DIR,$path) or die("can't readdir $path: $!"); # open the entire
directory for getting the contents of
while (my $file = readdir DIR) { # $file gets assigned the next value of
DIR, and exits when there's no more files
    my ($fname,$ext) = split(/\./,$file); # removes extension
    next if $file eq '.' or $file eq '..' or $ext ne 'html'; # goes to next
look if $file is . (current dir) or .. (parent dir)
    $lcfile = lc($file);
    print "renaming $file to $lcfile\n";
    system(qq~mv $path/$file $path/$lcfile~); # rename
}
closedir DIR; # close directory
__ END __

i changed the "rename" line to a system call, using move (mv). works fine
for me, and it renames the files. the "print" statement is just there to
tell you which one it's doing. if you want it to work silently, just take
that line out.


dan

"Dan" <[EMAIL PROTECTED]> wrote in message
news:20021104183421.83888.qmail@;onion.perl.org...
> try this..
>
> __ START __
> my $path = qq~$HOME/documents~; # set this to your path
> opendir(DIR,$path) or diesub("can't readdir $path: $!"); # open the entire
> directory for getting the contents of
> while (my $file = readdir DIR) { # $file gets assigned the next value of
> DIR, and exits when there's no more files
>     my ($fname,$ext) = split(/\./,$file); # removes extension
>     next if $file eq '.' or $file eq '..' or $ext ne 'html'; # goes to
next
> look if $file is . (current dir) or .. (parent dir)
>     rename $file, lc($file); # rename
> }
> closedir DIR; # close directory
> __ END __
>
> dan
>
> P.S: This is untested.. test/alter/correct/test as need be.
>
> "Desmond Coughlan" <[EMAIL PROTECTED]> wrote in message
> news:20021103180226.GE15981@;lievre.voute.net...
>
> Hi,
> I'm trying to figure out how I can change the filenames in a directory,
from
> having an initial capital letter, to all lowercase.  The files came from
> a Windows system, which doesn't really care about case.  My BSD box,
> however,
> does !
>
> I've tried fiddling around with tr and lc, but I don't know perl enough
> to get it to work.  FYI, the directory is called $HOME/documents, and
> the files are called 'Indexpage.html', or 'Reportback.html' and so on ...
>
> Thanks in advance.
>
> D.
>
> --
> Desmond Coughlan
> [EMAIL PROTECTED]
> http://www.zeouane.org
>
>
>



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to