FILEFUN is created in the same spirit as e.g. CELLFUN, in that it repeatedly calls the same function FUN with different arguments, in this case filenames. It will then collect the output(s) of the function into concatenated arrays of the same type as FUN delivers, or encapsulated individually in cell arrays.
The filename argument to FILEFUN may contain wildcards(*) and FILEFUN may optionally traverse subdirectories recursively.
FILEFUN can also be called without the FUN argument, turning it into a recursive wildcard file finder.
See 'help filefun' for extensive help and more examples.
Open all figure files in current directory:
Pick a couple of image files and compute their mean RGB values:
pth=fullfile(matlabroot, 'toolbox', ...
'matlab', 'demos', 'html', filesep);
[filenames,pathname]=uigetfile('*.png','Pick files', ...
Jerker Wagberg (2021). filefun: Apply a function to files (https://www.mathworks.com/matlabcentral/fileexchange/9723-filefun-apply-a-function-to-files), MATLAB Central File Exchange. Retrieved .
Sorry. It does indeed run quite nicely on the mac. The author referred to '\' in his comments, but uses filesep in the code itself. Very good. A great tool if you wish to process evey jpeg file in a directory tree, or a variety of other tasks.
This looks very nice. I can only offer one enhancement - instead of using the fixed '\' as a separator in paths, use filesep instead. Filesep provides the correct separator for various operating systems. For example, a mac needs '/'.
Inspired by: parse_pv_pairs
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!