File Exchange

image thumbnail


version (3.32 KB) by Bob Hamans
Searches the file system for files or folders matching a wildcard pattern


Updated 20 Sep 2007

View License

WILDCARDSEARCH(ROOTDIR, SEARCHSTRING) Searches the file system from the starting directory ROOTDIR for files and folders matching the pattern SEARCHSTRING. The function WILDCARDSEARCH is similar to the search file option in Explorer.

Have a look at the source code for more information. For more info on this function and how to use it, bug reports, feature requests, etc. feel free to contact the author.

Cite As

Bob Hamans (2021). wildcardsearch (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (4)

Glenn Gomes

Well written and very useful.

Small bug was crashing program when it encountered empty folders, which has been fixed.

A version has been written to work over FTP servers (including passive mode), so that you can search for files recursively and upload all files matching specified criteria.



Bob Hamans

Example 1: Finds all jpg and tif files:
rootdir = 'C:\'
searchstr = '*.jpg;*.tif';
files = wildcardsearch(rootdir, searchstr);

Example 2: Finds all files named EXPxxx.DAT:
rootdir = 'C:\'
searchstr = 'EXP???.DAT';
files = wildcardsearch(rootdir, searchstr);

MATLAB Release Compatibility
Created with R2007a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!