<<< Date Index >>>     <<< Thread Index >>>

Re: Reliable/safe way of removing empty maildirs?



On Thu, Dec 06, 2007 at 09:15:10PM +0000, A Darren Dunham wrote:
> > >> chmod a-w dir/new
> > >> if [ `find dir -type f` ] ; then
> > >
> > > You have to do something like this instead:
> [snip other responses]
> 
> Perhaps I've misunderstood the reason for doing this, but I would just
> ask find to do a rmdir, and let it fail if the directory isn't empty.
> 
> find dir -depth -type d -exec rmdir {} \;
> 
> If 'dir' is still around when that finishes, it's probably because
> there's a file in there now.  In the meantime, it's removed all empty
> subtrees.
> 
... and left an *awful* mess, a maildir mailbox is a directory with
*three* sub-directories in it, you need to check that all three are
empty before removing them.

-- 
Chris Green