Because they only want the empty ones, and this code is cross platform?

Ilene

----- Original Message ----- 
From: "Messenger, Mark" <[EMAIL PROTECTED]>
To: "John Deretich" <[EMAIL PROTECTED]>;
"Perl-Win32-Admin-Request (E-mail)"
<[EMAIL PROTECTED]>
Sent: Tuesday, September 30, 2003 4:57 PM
Subject: RE: removing empty directories


> Dumb question:  Why not use 'rd'?  Rd is included in NT4/2000/XP.
>
> Example:
>   `"rd /s /q \"c:\\some dir to delete\""`;   # /s = kill sub dirs    /q =
quiet.
>
>
>
> -----Original Message-----
> From: John Deretich [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, September 30, 2003 3:05 PM
> To: Perl-Win32-Admin-Request (E-mail)
> Subject: removing empty directories
>
>
> Hello,
>
> I was wondering if anyone has a script that
> will remove empty directories and subdirectories.
> The code that I am using will delete the entries
> at the first sublevel but not at multiple sublevels.
>
> Here's my code:
>
> opendir(EMPTYDIR, $searchdrive1) ;
> while ($directoryempty  = readdir(EMPTYDIR)) {
>    if ($directoryempty ne "." && $directoryempty ne "..") {
>        $directoryempty = $searchdrive1 . "\\" . $directoryempty;
>          if (-d $directoryempty) {
>              opendir(EMPTY, $directoryempty);
>                  while ($subdirectoryempty  = readdir(EMPTY)) {
>                        if ($subdirectoryempty ne "." && $subdirectoryempty
> ne "..") {
>                           $subdirectoryempty = $directoryempty . "\\" .
> $subdirectoryempty;
>                           system ("rmdir \"$subdirectoryempty\" ") || warn
> "Cannot remove $subdirectoryempty: $! \n";
>                            }
>                      }
>              system ("rmdir \"$directoryempty\" ") || warn "Cannot remove
> $directoryempty: $! \n";
>             }
>        }
>   }
>
> I have File::Path but when I run it, it will remove more than what I need.
>
> thanks,
>
> John
> _______________________________________________
> Perl-Win32-Admin mailing list
> [EMAIL PROTECTED]
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
>
> _______________________________________________
> Perl-Win32-Admin mailing list
> [EMAIL PROTECTED]
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to