Load files in a loop

3 visualizaciones (últimos 30 días)
Ellen
Ellen el 6 de Abr. de 2015
Respondida: Image Analyst el 6 de Abr. de 2015
Hi, I didn't see an answer to this question anyway, and it's very possible I missed it. But I was wondering if anyone could help me load files in several folders in a loop.
The situation I have is folder A with folders AA,BB,CC within. AA contains A1,A2,A3, BB contains B1,B2,B3 and CC contains C1,C2,C3. But withint AA,BB,CC I only want the 15 files contained in the second folder.
I tried this:
cd('C:\A');
fault = dir(cd)
for i=3:length(fault); data=dir(fault(i));
for ii=3:length(data);
data2=dir(data(ii));
end
end
But that clearly didn't work.
Any suggestions?

Respuestas (1)

Image Analyst
Image Analyst el 6 de Abr. de 2015
Check out the attached demo where I get all subfolders of a folder and go into all the folders getting the names of all the files in each folder. I use genpath() and dir(). Feel free to adapt the file patterns you pass to dir() as needed for your situation.

Categorías

Más información sobre File Operations en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by