Read files from folder with specific name
36 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Kris zenitis
le 1 Juil 2014
Commenté : Image Analyst
le 17 Août 2022
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 commentaires
Réponse acceptée
Image Analyst
le 1 Juil 2014
Files=dir('word*.*');
7 commentaires
Ihaveaquest
le 16 Août 2022
what if there are multiple files with similar name but you only want the most current created ??
Image Analyst
le 17 Août 2022
@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)
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur File Operations dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!