I've been looking for a quick and easy way to remove empty maildir folders, I was going write a short shell script but while I was thinking about this I came across 'rmdir -p'. Thinking that this was sort of equivalent to 'mkdir -p' I tried to use it and it acts very strangely.
If you have an empty maildir folder called (for example) mdf then "rmdir -p mdf" simply gives the error "rmdir: mdf: Directory not empty", it doesn't recurse down into the directory and find that the sub-directories are empty and them remove the lot.
If you give the command "rmdir -p mdf/*" then it gives the error "rmdir: mdf: Directory not empty" twice but does actually remove the whole maildir folder. What's happening is that it removes each of the 'cur', 'tmp' and 'new' sub-directories of 'mdf' but only when it removes the last one does it also remove the parent directory.
I can think of no practical use for this command! :-)
It's no good for my requirement because it might remove some of the maildir sub-directories then find the next one wasn't empty and leave a partial maildir folder.
I think I'm back to my script for doing it.