Re: ensure-directories aka create-directories Lassi Kortela 31 Jul 2020 13:14 UTC

> Python has an inverse operation as
> well that is not a full rm -rf:  given foo/bar/baz it removes it, then
> removes foo/bar, then removes foo.  The usual rules for rmdir() apply.
> The Python version silently stops if any directory is non-empty, does
> not exist, etc., but clearly an exception should be raised.   I'm not
> sure that this is quite as strong a candidate.

This is nice to have but is not as often needed, and the desired
semantics are not as clear: if we have a whole tree full of empty
directories, would it make more sense to delete all of them? Doing a
naive check for an empty vs non-empty directory would consider a tree of
empty directories (with more than one branch at some depth) non-empty.
Also, should zero-byte files count as empty?

Incidentally I wrote a program last year to remove empty trees from the
command line: <https://github.com/lassik/rmempty>.