Extracting files of the same name only from the first level of subdirectories
조회 수: 2 (최근 30일)
이전 댓글 표시
I have a folder structure with three levels, A, B, and C. Level A only contains the folders for B, and each B folder contains a file that I want. However, some B folders may contain a C level that also contains the file, but I do not want it. I would like to use the recursive check with dir search to find all the B level files, but don't know how to keep away from the C level files.
list = dir(fullfile(Alevel,'**','filename.txt')); % Returns filename.txt locations in B and C levels
Is there a way to use dir to exclude the C level results?
댓글 수: 0
채택된 답변
Turlough Hughes
2021년 5월 18일
편집: Turlough Hughes
2021년 5월 18일
Hey Bob, a single star will go down one level only, so try the following:
list = dir(fullfile(Alevel,'*','filename.txt'))
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 File Operations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!