Azzera filtri
Azzera filtri

Read files from folder with specific name

37 visualizzazioni (ultimi 30 giorni)
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?

Risposta accettata

Image Analyst
Image Analyst il 1 Lug 2014
Files=dir('word*.*');
  7 Commenti
Ihaveaquest
Ihaveaquest il 16 Ago 2022
what if there are multiple files with similar name but you only want the most current created ??
Image Analyst
Image Analyst il 17 Ago 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)

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su File Operations in Help Center e File Exchange

Tag

Non è stata ancora inserito alcun tag.

Community Treasure Hunt

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

Start Hunting!

Translated by