The command
dir *.bmp
will print to the command window the names of all files in the current directory ending with the extension .bmp. I know the following is not valid MATLAB syntax, but is there a command that would be the equivalent of
fileList = dir *.bmp;
I want to create a list of all files ending with a specific extension using minimal code. Currently I have the following:
files = dir;L = length(files);index = false(1, L);for k = 1:L M = length(files(k).name); if M > 4 && strcmp(files(k).name(M-3:M), '.bmp') index(k) = true; endendimages = files(index);
There must be a simpler way. Thank you in advance for any comments.
Best Answer