Function File: filename = rsearchfile (dname, fname)
Function File: filename = rsearchfile (dname, fname, maxdepth)

Recursively search for file or filename pattern FNAME starting in directory DNAME and return the first match.

dname and fname must be character strings and should conform to the directory name and filename requirements of your operating system. Optional argument maxdepth can be specified to limit the maximum search depth; the default value is 1 (search only in dname and subdirs of dname). Setting maxdepth to 0 limits the search to dname. Be careful with setting maxdepth to values > 3 or 4 as this can provoke excessive search times in densely populated directory trees. Keep in mind that rfsearch is a recursive function itself.

Output argument filename returns the relative file path of the first match, relative to DNAME, or an empty character string if no match was found.

Examples:

filename = rfsearch ("/home/guest/octave", "test.fil")
Look for file test.fil and start the search in /home/guest/octave
filename = rfsearch ("/home", "test.fil", 2)
Look for file test.fil, start the search in /home, and if needed
search subdirs of subdirs of /home

See also: dir, glob.

Package: io