How to segregate folders level wise and list the files folderwise
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Mukund
am 5 Okt. 2019
Beantwortet: Image Analyst
am 5 Okt. 2019
In Matlab 2016 onwards, commands like dir(**/*.extension) is available. However, it lists all the file list with its Path. The task afterward is critical. 1. Obtain Subfolders 2. Obtain Files and Subsubfolders with their level. 3. Extract the directory name and file name in cell array.
Are there modified ways or shortcut commands to obtain this info.
0 Kommentare
Akzeptierte Antwort
Image Analyst
am 5 Okt. 2019
There is a .isdir property on the returned files that you can check. In addition there is a function called isfolder() that you can also use. Try this:
files = dir('**/*.*')
areFolders = [files.isdir]
folders = files(areFolders)
dotOrDotDot = strcmp('.', {folders.name}) | strcmp('..', {folders.name})
folders = folders(~dotOrDotDot)
folderNames = {folders.name}
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu File Operations finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!