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