If I have a directory structure as below and the prefix is /folder1,
/folder1/folder11/folder12/folder13/*.files
/folder21/folder22/folder23/*.files
/folder31/folder32/*.files
I want to loop through these directories dynamically in order to read files in each of the leaf folder separately, i.e. I'd need a list
[
/folder1/folder11/folder12/folder13/,
/folder1/folder21/folder22/folder23/,
/folder1/folder31/folder32/
]
Is there a better way to get it other than loop through each prefix recursively, get next level prefix, concatenate, get next level, etc., until you get to the last (leaf) folder?