Supposing this file system structure:
ROOT
DIR1A
FILE
DIR2A
DIR2B
DIR3A
DIR1B
DIR2C
DIR2D
DIR3B
DIR1C
DIR2E
FILE
Starting from an arbitrary directory, how can I list only the shallowest of it's child directories which in turn contain either a) nothing or b) only empty directories all the way down, but without listing said empty children?
That is, in the case above, if I started at ROOT:
- DIR1A would NOT be listed, because it contains a file.
- DIR2A WOULD be listed, because it contains nothing.
- DIR2B WOULD be listed, because it contains only empty directories.
- DIR3A would NOT be listed, because it is within a shallower directory that's already been listed.
- DIR1B WOULD be listed, because it contains only empty directories.
- Children of DIR1B would NOT be listed, because they are within a shallower directory that's already been listed.
- Both DIR1C and DIR2E would NOT be listed, because there's a file nested in there.
I'm confident there's a more efficient way to say this. Perhaps "I want to list only the highest-order directories which contain either nothing or solely empty directories, all the way down"?
EDIT: I attempted to clarify some of the language above.