How to remove empty directory names such as '.' '..' returned by "dir" function?
40 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
MathWorks Support Team
am 19 Nov. 2020
Beantwortet: MathWorks Support Team
am 19 Feb. 2021
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?
Akzeptierte Antwort
MathWorks Support Team
am 19 Nov. 2020
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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu File Operations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!