The function uses the MATLAB "dir" function to create a structure of sub-directories.
Paul Macey (2020). dirdir (https://www.mathworks.com/matlabcentral/fileexchange/1570-dirdir), MATLAB Central File Exchange. Retrieved .
This is good - but caution - if in the root directory of a disc '.' and '..' are not returned in dir, so you potentially lose a sub dir. I've added a test, D(i).name == '.' to test for this and adjust accordingly.
Very handy and simple to use. Thank you very much Paul!
This is exactly what I needed. I'm glad I found it on the Matlab File Exchange. Nice job Paul.