Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Need to delete empty directories.

by sh1tn (Priest)
on Mar 09, 2005 at 12:49 UTC ( [id://437882]=note: print w/replies, xml ) Need Help??


in reply to Need to delete empty directories.

use File::Find; my @dirs; my @search_dirs = qw(. ..); find(\&wanted, @search_dirs); sub wanted { -d && push @dirs, $File::Find::name } # do sm.th. with directories in @dirs


Replies are listed 'Best First'.
Re^2: Need to delete empty directories.
by sashac88 (Beadle) on Mar 09, 2005 at 13:02 UTC
    I can delete empty directory with rmdir.
    Since if I delete some directory -it's parent directory can
    become empty-I need to delete it too.
    Thus what I need is loop of deletions of empty directories.
    However I want to limit this loop to the maximum
    deepness.
    Thanks in advance.
      use strict; use File::Find; my @topdirs = @ARGV; my @rmdirs; find( sub { -d and push @rmdirs, $File::Find::name }, @topdirs ); rmdir for reverse @rmdirs;


Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://437882]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2024-04-25 07:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found