Read files from folder with specific name
20 次查看(过去 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 中查找有关 Data Import and Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!