How to remove empty directory names such as '.' '..' returned by "dir" function?
38 ビュー (過去 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!