-----Original Message-----
From: Porter, Chris 
Sent: Wednesday, June 27, 2001 9:21 AM
To: 'Maxim Berlin'
Subject: RE: FW: rmdir


Hi,

It's working great.  Thank you.  But one more thing, it's removing all the
empty directories but what about directories with files in them.  It errors
out when it hits a directory with files in it.  I have just files in this
directory that I don't want to delete.  I only want to delete the
directories with Capital letters and the files in them.  Thank you for any
help or ideas.

Chris

-----Original Message-----
From: Maxim Berlin [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, June 26, 2001 10:07 AM
To: '[EMAIL PROTECTED]'
Subject: Re: FW: rmdir


Hello Chris,

Tuesday, June 26, 2001, Porter, Chris <[EMAIL PROTECTED]> wrote:

PC> It's me again, still won't work.  Here is the whole script:
PC> Again, any help would be great.

Well, script works correct now.

May be you try to rmdir not empty subdirs?

c:\>perldoc -f rmdir
    rmdir FILENAME
    rmdir   Deletes the directory specified by FILENAME if that
            directory is empty. If it succeeds it returns TRUE,
            otherwise it returns FALSE and sets `$!' (errno). If
            FILENAME is omitted, uses `$_'.

you can avoid many troubles, if you check return codes, like this:

rmdir $Name or die $!;
            
PC>  chdir "/u131/tmp" or die $!;

PC>  opendir(HERE, '.');

PC>  @AllFiles = readdir(HERE);

PC>  foreach $Name (@AllFiles) {

PC>    if (-f $Name) {next}

PC>    if ((-d $Name) and ($Name =~ /^[A-Z]+$/)) {rmdir $Name}


PC>    if ((-d $Name)) {print "$Name\n"}

PC>    }                          



Best wishes,
 Maxim                            mailto:[EMAIL PROTECTED]

Reply via email to