How do I get only the subfolders of a folder?
The "dir" command gives a struct with all the subfolders as well as all the files and '.', '..'.

 채택된 답변

MathWorks Support Team
MathWorks Support Team 2020년 4월 30일
편집: MathWorks Support Team 2020년 4월 30일

13 개 추천

The following code, returns a struct containing only the subfolders of a folder.
% get the folder contents
>> d = dir('foldername')
% remove all files (isdir property is 0)
>> dfolders = d([d(:).isdir])
% remove '.' and '..'
>> dfolders = dfolders(~ismember({dfolders(:).name},{'.','..'}))

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 File Operations에 대해 자세히 알아보기

제품

릴리스

R2016a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by