checking folder has more than one file with similar name

2 ビュー (過去 30 日間)
HYZ
HYZ 2022 年 9 月 9 日
編集済み: Voss 2022 年 9 月 9 日
Hi,
I want to check if a folder has files starting with same name.
Eg in a folder, there are files ('test01.mat' , 'test02.mat', 'test03.mat' etc). they start with "test".
how can I check that? thanks.

採用された回答

Voss
Voss 2022 年 9 月 9 日
編集済み: Voss 2022 年 9 月 9 日
% use the name of the folder you want to check:
folder = './';
% get info about the files in that folder whose name starts with 'test' and
% whose extension is .mat:
files = dir(fullfile(folder,'test*.mat'));
% see the files' names:
{files.name}
ans = 1×3 cell array
{'test01.mat'} {'test02.mat'} {'test03.mat'}
% and/or, see if there is more than one such file:
numel(files) > 1
ans = logical
1
% etc.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeVerification, Validation, and Test についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by