Is it possible to list all of the files in a directory of a certain file type, and then save them in the same directory but as a separate file type using MatLab?
In my case, I have 144 files saved as in a .fig format, but I would like to copy them as a .tif format so that I don't have to go and change each file manually.
I know I can list all the files in my directory using the dir
function and I guess I could simply run for
loop with i=1:length(dir)
but I don't know how to isolate the files of a specific file type. I don't see filetype as a field name on the mathworks website for dir
.
Thanks for any suggestions.
To list only files of type .fig
:
files = dir('*.fig');
You can then loop over the names:
for k = 1:numel(files)
filename = files(k).name;
% do something with filename
end