列出与特定通配符模式匹配的文件夹名称

时间:2017-11-21 07:15:26

标签: matlab file file-manipulation

下面显示的Matlab脚本列出了当前目录中的所有文件夹。如何列出符合特定通配符模式的所有文件夹,例如*pattern*Sample*

files = dir(pwd)
% Get a logical vector that tells which is a directory.
dirFlags = [files.isdir]
% Extract only those that are directories.
subFolders = files(dirFlags)
% Print folder names to command window.
for k = 1 : length(subFolders)
    fprintf('Sub folder #%d = %s\n', k, subFolders(k).name);
end

0 个答案:

没有答案