I got a root directory with 100s of dynamically generated folders. As time goes some of these folders will need to be extirpated from system on the condition that this(ese) directories(s) must be empty. What would be the best shortest, easiest and/or most effective way to achieve that?
Use glob
:
if (count(glob("path/*")) === 0 ) { // empty
A nice thing about glob
is that it doesn't return .
and ..
directories.