Read files from folder with specific name
조회 수: 36 (최근 30일)
이전 댓글 표시
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?
댓글 수: 0
채택된 답변
Image Analyst
2014년 7월 1일
Files=dir('word*.*');
댓글 수: 7
Ihaveaquest
2022년 8월 16일
what if there are multiple files with similar name but you only want the most current created ??
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 Center 및 File Exchange에서 File Operations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!