フィルターのクリア

How to get files from specific subfolder with unspecific folder?

1 回表示 (過去 30 日間)
Diego Alcoceba Alvarez
Diego Alcoceba Alvarez 2018 年 2 月 5 日
回答済み: Diego Alcoceba Alvarez 2018 年 2 月 20 日
Hi all!
I'm stucked with getting files contained within a determined subfolder which is contained on a variable folder's name. How is this situation possible?
For example, I have 45 lessons, so I create 45 folders (Lesson 1, Lesson 2, etc.). For each lesson I have both Theory and Exercises -> MasterFolder\Lesson1\Theory and MasterFolder\Lesson1\Exercises; MasterFolder\Lesson2\Theory and MasterFolder\Lesson2\Exercises; etc.
So, the question is: how do I get all Exercises without executing the script for each "Lesson folder"?
Thanks in advance, Diego A.

採用された回答

Diego Alcoceba Alvarez
Diego Alcoceba Alvarez 2018 年 2 月 20 日
After all, i found the solution. I add in the following lines the code in order to help those people with the same trouble:
% Define a starting folder.
start_path = fullfile('D:','Course in Matlab','MasterFolder');
filePattern = sprintf('%s/**/Exercises/*.mat', start_path);
baseFileNames = dir(filePattern);

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by