필터 지우기
필터 지우기

Extract files of specific extension from already searched folder

조회 수: 4 (최근 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 CenterFile Exchange에서 File Operations에 대해 자세히 알아보기

제품


릴리스

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by