List of all subfolders and theire subfolders etc.

조회 수: 192 (최근 30일)
Drach
Drach 2019년 3월 7일
편집: M J 2020년 9월 22일
Hello everybody,
I have a directory and I want to create a list that contains the paths of all subfolders within that directory and all subfolders within every subfolder in that list and so on.
I'm actually looking for specific folders that contain a number of specific files. The directory I'm working on has x amount of "layers" of subolders. I tried to use a recursive function to get those specific folders but I can't quite make it. So my second approach is just to get a huge list of every folder (including all subfolders, theire subfolders, and so on...) and its path within my main directory and then in a second step check everyone of those folders individually for these specific files.
Is there a way to get all those folders within a directory? I've got the feeling I'm missing an easy approach here.
Thanks alot in advance!

채택된 답변

Fangjun Jiang
Fangjun Jiang 2019년 3월 7일
Yes. list=dir('**/*.*') will do it. Then check for list.isdir
  댓글 수: 4
Fangjun Jiang
Fangjun Jiang 2020년 9월 18일
You probably could do some processing, such as counting the number of "/" in the path after getting all the subfolders.
M J
M J 2020년 9월 22일
편집: M J 2020년 9월 22일
Found a way to do it, thank you very much!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Search Path에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by