Tuesday, October 2, 2012

Make Matlab listing ONLY subfolders cointained into a folder

From the Matlab Command Window when you type "dir" you get a list of files and folders contained in your working directory.
The question is: how can you get ONLY the folders?

Here is the solution from stackoverflow.

NOTE
In the following function the output "nameFolds" is a cell variable type!!!

------------------------------------------------------------------------------------------

function nameFolds=ListSubfolders(pathFolder)

d = dir(pathFolder);
isub = [d(:).isdir];
nameFolds = {d(isub).name}';
nameFolds(ismember(nameFolds,{'.','..'})) = [];

 -----------------------------------------------------------------------------------------

Credits:
stackoverflow

No comments:

Post a Comment

Your comment will be visible after approval.