How to make a script so I can choose a file from folders

조회 수: 2 (최근 30일)
Luís Mira
Luís Mira 2021년 4월 3일
답변: dpb 2021년 4월 4일
I'm in my last year of graduation and I'm doing a research project about space weather. To summarize, I've some data distributed by several folders. There are many folders inside each one and I have to build a script to pick each folder content. How should I do it?

답변 (1개)

dpb
dpb 2021년 4월 4일
While it's only documented by a very terse example, the builtin dir function will recurse directories if the search pattern contains "**/" preceding the pattern given for the file match itself.
That is,
d=dir('**/*.xlsx');
will return all Excel files of the explicit .xlsx type from the current directory and all subdirectories below. Giving a specific top level directory of the data storage location in combination with the wildcard will give you the full structure below that location.
You'll also want to explore fullfile and fileparts in processing the results and in preparing the input filename strings.

카테고리

Help CenterFile Exchange에서 File Operations에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by