[Following up to myself here]

It's working now. Not sure why, but adding an extra check does the trick:


#!perl -w
use strict;
use File::Find;

finddepth (sub {
                rmdir $_ if -d;
               }, 'Hard Disk:Support:');


Now only empty folders are removed. Tested on Mac OS 8.6 and MacPerl
5.6.1r1.


Best regards,
Ricardo Montiel
----------------------------------------------------------------------
Colaborador de [ALDEA]mac <http://www.aldeamac.com.ar>
Traductor de TidBITS-es (Versión en Castellano de TidBITS)
<http://www.tidbits.com/tb-issues/lang/es>
----------------------------------------------------------------------


in article [EMAIL PROTECTED], Ricardo Montiel at
[EMAIL PROTECTED] wrote on 08/08/02 19:40:

> On 08/08/02 18:39, Bart Lateur at [EMAIL PROTECTED] wrote:
> 
>> On Thu, 08 Aug 2002 17:17:12 -0300, Ricardo Montiel wrote:
>>> [...] 
>>> }, 'Hard Disk:Support:);     # thanks merlyn
>> 
>> But still you forgot a closing quote o,n the path.
> 
> Yup, after editing a long path, I forgot the closing quote.
> 
>>> 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.
> 
> Thanks Bart, unfortunately it didn't work. When I tried:
> 
> #!perl -w
> use strict;
> use File::Find;
> 
> finddepth (sub {
> print $File::Find::name, "\n";
> rmdir $File::Find::name;
> }, 'Hard Disk:Support:');
> 
> 
> --->    output:
> 
> Hard Disk:Support:untitled folder 1
> Hard Disk:Support:untitled folder:MAC TIPS 'N' TRICKS
> Hard Disk:Support:untitled folder
> Hard Disk:Support:
> 
> 
> both folders - untitled folder 1 and untitled folder (containing the 'MAC
> TIPS 'N' TRICKS' file) - are deleted.
> 
> 
> Best regards,
> -- Ricardo
> 

Reply via email to