Extract files of specific extension from already searched folder

6 ビュー (過去 30 日間)
Mukund
Mukund 2019 年 10 月 10 日
編集済み: Stephen23 2019 年 10 月 10 日
Myfolder contains various filetypes (various extensions). File search step is completed with
Myfolder=dir('*.*')
Instead of repeated search with 'dir' command for each filetype, is it possible to extract filenames from 'Myfolder'(already searched) based on extensions like *.xlsx, *.fig, *.bmp?

採用された回答

Stephen23
Stephen23 2019 年 10 月 10 日
編集済み: Stephen23 2019 年 10 月 10 日
>> S = dir('*.*');
>> S.name
ans = .
ans = ..
ans = archive
ans = iregexp.m
ans = iregexp.png
ans = iregexp.zip
ans = iregexp_doc.m
ans = iregexp_zip.m
>> [~,~,E] = cellfun(@fileparts,{S.name},'uni',0);
>> X = strcmpi(E,'.m');
>> T = S(X);
>> T.name
ans = iregexp.m
ans = iregexp_doc.m
ans = iregexp_zip.m
  1 件のコメント
Mukund
Mukund 2019 年 10 月 10 日
Thanks Stephen! With these four useful steps, the requisite solution is found.

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

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by