Azzera filtri
Azzera filtri

loop Will only open the files in starting folder

62 visualizzazioni (ultimi 30 giorni)
Bertrand
Bertrand il 19 Mag 2024 alle 0:25
Commentato: Bertrand il 20 Mag 2024 alle 21:13
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

Risposta accettata

Voss
Voss il 19 Mag 2024 alle 22:51
matFiles = dir(fullfile(pwd,'**','*.mat'));

Più risposte (0)

Categorie

Scopri di più su Environment and Settings in Help Center e File Exchange

Prodotti

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by