Grabbing all files in a folder

368 ビュー (過去 30 日間)
Jason
Jason 2011 年 4 月 7 日
コメント済み: Jeong Dae Kim 2021 年 8 月 1 日
Is there anyway in matlab to grab all the files in a folder that the user select? Kind of like the uigetfile() command but that only grab the file selected. I want a way where user can select the folder and matlab will grab all the files inside of that folder. Even better if matlab can grab particular files base on the name of those files.

採用された回答

Jiro Doke
Jiro Doke 2011 年 4 月 7 日
Take a look at uigetdir and dir. For example, if you want to pick out all the JPG files in a folder that the user selects:
d = uigetdir(pwd, 'Select a folder');
files = dir(fullfile(d, '*.jpg'));
% Display the names
files.name
  2 件のコメント
Jenna
Jenna 2013 年 6 月 1 日
In this case, what kind of data type is files?
Jeong Dae Kim
Jeong Dae Kim 2021 年 8 月 1 日
struct

サインインしてコメントする。

その他の回答 (1 件)

Robert Cumming
Robert Cumming 2011 年 4 月 7 日
if you set use the following syntax you can select multiple files:
uigetfile('*.m', 'Select Multiple Files', 'MultiSelect', 'on' )
or you can use
uigetdir
to select a directory, then use the ls command to get a list of files in that directory.

カテゴリ

Help Center および File ExchangeFile Operations についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by