matFiles = dir(fullfile(pwd,'**','*.mat'));
loop Will only open the files in starting folder
1 次查看(过去 30 天)
显示 更早的评论
I want to create a script that opens a folder and goes in to every subfolder and pulls out .mat files. The following code only pulls out the .mat files that are located in the starting fold even though it gathers all sub folder directories. Any help would be greatly appreciated!
startingFolder = pwd;
root = uigetdir(startingFolder);
allSubfolders = genpath(root);
subFolders = regexp(allSubfolders, ';', 'split');
for subFolderCount = 3 : length(subFolders)
% Get this subfolder.
thisSubFolder = subFolders{subFolderCount};
% Get a list of MAT files in this subfolder.
matFiles = dir(fullfile(thisSubFolder, '*.mat'));
end
0 个评论
采纳的回答
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Environment and Settings 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!