findFileInFolder(parentFolderPath, fileExtension, varargin)
This function is an update of an old one (submitted in 2013) I decided to delete. This version is cleaner, shorter and more efficient than the previous one.
It recursively searches for specified file names and extensions (with or without respect to letter case) in a given directory and its sub-directories.
Example: findFileInFolder(pwd, {'.m', '.zip', '.mat'}) match all files with the corresponding extensions ('.m', '.zip', '.mat') in the current directory
More information in the m-file
Cite As
Benjamin Pillot (2025). findFileInFolder(parentFolderPath, fileExtension, varargin) (https://www.mathworks.com/matlabcentral/fileexchange/59357-findfileinfolder-parentfolderpath-fileextension-varargin), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform Compatibility
Windows macOS LinuxCategories
Tags
Acknowledgements
Inspired: Normal and recursive extraction from multi-format archive
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.