필터 지우기
필터 지우기

Read files from folder with specific name

조회 수: 36 (최근 30일)
Kris zenitis
Kris zenitis 2014년 7월 1일
댓글: Image Analyst 2022년 8월 17일
I am using the following code to read all files from a folder:
Files=dir('*');
for k=1:length(Files)
FileNames=Files(k).name;
end
However I want to read the files which names begin with "word" not just all files in folder. How can I perform such task?

채택된 답변

Image Analyst
Image Analyst 2014년 7월 1일
Files=dir('word*.*');
  댓글 수: 7
Ihaveaquest
Ihaveaquest 2022년 8월 16일
what if there are multiple files with similar name but you only want the most current created ??
Image Analyst
Image Analyst 2022년 8월 17일
@Ihaveaquest, to find the newest file, do this:
fileList = dir('t*.m')
fileDates = [fileList.datenum]
% Find newest file
[maxDate, index] = max(fileDates)
fprintf('The newest file is:\nName: %s\nDate: %s\n', ...
fileList(index).name, fileList(index).date)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

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

태그

아직 태그를 입력하지 않았습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by