On Thu, Sep 24, 2009 at 08:26:53AM +0200, Christian Ebert wrote: > * Wu, Yue on Thursday, September 24, 2009 at 09:24:35 +0800 > > > > I don't know sh, and I've tried the following sh script, but it doesn't > > work: > > > > #!/bin/sh > > > > DIR="~/temp/mails/*" > > > > for d in ${DIR}; do > > if [ $(find d -type f | wc -l) -eq 0 ] ; then > > rm -r d > > rm -r $d > > But I would be careful with rm while developing the script, perhaps do a > > echo $d
mutt owns the maildir at all, so I don't need to worry it :) > > first, to see what would be removed. > > > fi > > done > > I also think this does not work with a nested hierarchy. Try this > for a simple nested hierarchy: > > > mailhier="~/temp/mails" > > for md in `find $mailhier -type d \( -name cur -o -name new -o -name tmp > -execdir pwd \; \) -prune`; do > if [ `find "$md" -type f | wc -l` -eq 0 ]; then > echo "$md" > # rm -r "$md" > fi > done Thank you, I've take it down in my note for reference. James Michael's version seems more concise, so I will use that version :) -- Hi, Wu, Yue