On Thu, 08 Aug 2002 17:17:12 -0300, Ricardo Montiel wrote:

>I need to delete all empty folders (up to three sub-levels, if this matters)
>for a given location. But when I try the following:
>
>#!perl -w
>use strict;
>use File::Find;
># use Mac::Files;
>
>finddepth (sub {
>             rmdir $_;
>             # FSpDelete $_;
>           }, 'Hard Disk:Support:);     # thanks merlyn

But still you forgot a closing quote o,n the path.

>all the sub-level folders - either empty or with files inside them - are
>deleted, except the top-level folder ('Support:'). Bear in mind that I tried
>to make use of FSpDelete as well, but I get the same unwanted result.
>
>What am I doing wrong?

For the directory itself, the callback is called with $_ set to "." on
Unixy/Win systems (likely with ":" on a Mac -- ?). That's the only
directory for which that is the case. rmdir "." won't ever work. I thik
that if you'd do

        rmdir $File::Find::name;

likely it will work, because now it's no longer an exception: for all
directories, rmdir is called with the full path. I *think* it will work.

-- 
        Bart.

Reply via email to