How to remove empty directory names such as '.' '..' returned by "dir" function?
조회 수: 40 (최근 30일)
이전 댓글 표시
MathWorks Support Team
2020년 11월 19일
답변: MathWorks Support Team
2021년 2월 19일
I am using "dir" function to read folder names from a particular directory. Sometimes the function returns some empty or hidden folder names such as "." or "..". How can I get rid of these empty folder names?
채택된 답변
MathWorks Support Team
2020년 11월 19일
This workflow can be achieved by filtering and removing the folder names which match to that pattern such as such as '.' '..' by using indexing.
For example,
files = dir;
folderNames = {files([files.isdir]).name};
folderNames = folderNames(~ismember(folderNames ,{'.','..'}));
댓글 수: 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!