MATLAB: How to get all file extentions from a folder

file extensions

Hello everyone,
I have a folder which can contain images in different formats like .png, .jpg, .tif, …and so on.
How can I get the information which extensions are present in the folder?
Best regards

Best Answer

Try this
files = dir('*');
files([files.isdir]) = [];
[~, ~, ext] = cellfun(@(fn) fileparts(fn), {files.name}, 'uni', 0);
ext = unique(ext);