Notifications
Clear all

[Closed] Getting all Sub-Folders of a directory

I know about GetDirectories however it only goes one depth in (the folders immediately in that folder). Is there an easy way without writing an intelligent recursive folder finder to just get all sub directories?

1 Reply

sure is! You may recall there’s an example function in the reference called ‘getFilesRecursive’. Well the first part of the function gets directories recursively so if you just want that part, it would be like this:

fn getDirsRecursive root = 
(
dir_array = GetDirectories (root + "/*")
for d in dir_array do
join dir_array (GetDirectories (d + "/*"))
dir_array
)

now I have found that this function does not collect the root directory into dir_array so you can simply change (root + “/*”) to root and it will.