folder in a directory
古いコメントを表示
How do you use dir to obtain the names of folders in a directory. I can use
files = dir('*.xls');
to obtain information on the excel files within a specified directory but I have a directory which has 4 folders by using dir I obtain the names of each of the files, how is it possible to save the name of each file so that I can refer to each older within a loop.
cheers
採用された回答
その他の回答 (1 件)
David Young
2011 年 12 月 1 日
It's perhaps worth noting that 'folder' and 'directory' mean the same thing. Anyway, do you want something like this:
files = dir; % assume starting from current directory
filenames = {files.name};
subdirs = filenames([files.isdir]);
for s = 1:length(subdirs)
subdir = subdirs{s};
% process subdirectory
disp(subdir); % for example
end
5 件のコメント
ricco
2011 年 12 月 1 日
David Young
2011 年 12 月 1 日
'.' is the current directory. '..' is the parent of the current directory (the directory that contains the current directory).
ricco
2011 年 12 月 1 日
ricco
2011 年 12 月 1 日
ricco
2011 年 12 月 1 日
カテゴリ
ヘルプ センター および File Exchange で File Operations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!