Desktop Tools and Development Environment Previous page   Next Page

Finding Files and Content Within Files

Use the Find Files tool to search for files or for specified text within files.

Image of Find Files dialog box showing key features.panel of results.

To search for files in one or more directories, or to search for specified text in files, follow these instructions:

  1. Open the Find Files tool by clicking the Find Files button in the Current Directory browser toolbar, or by selecting Edit -> Find Files from the Edit menu in any desktop tool, such as the Current Directory browser or the Editor/Debugger.
  1. The Find Files dialog box opens.

  1. Type in the filename or text you are searching for:
  1. Use the dropdown list to view and select previous entries from the current MATLAB session.

  1. From the Look in list box, select the directories to search in. You can instead type the full pathname for one or more directories into this field (with each pathname separated by a semicolon ;). Or select the Browse option at the end of the list box. To include subdirectories in the search, select the Include subdirectories check box.
  1. For example, search the MATLAB current directory.

  1. To specify additional search criteria, click Advanced Options.
  1. For example, select *.m in the In file type field to limit the search to M-files only. The default, *, searches all file types.

    By default, a text search looks for partial matches (the Contains text option for Search type). You can instead select Matches whole word.

  1. To execute the search, click Find. While the search is in progress, the Find button label changes to Stop Find. To abort a search, click Stop Find.
  1. Search results appear in the pane on the right side of the Find Files dialog box, with a summary of the results at the bottom of the pane. For text searches, the line number and line of code are shown. To see the full pathnames for the files, select the Show full pathnames check box under Advanced Options.

  1. Click a column heading to sort the results based on that column. Click the column heading again to reverse the sort order for that column. For example, click Line to sort results by line number.

You can open any M-files that appear in the results list by doing one of the following:

The M-files open in the Editor/Debugger. For text searches, the file opens scrolled to the line number shown in the results section of the Find Files dialog box. Once in the Editor/Debugger, you can use the Find & Replace tool to replace specified text.

To see the results of a previous search, select its tab at the bottom of the results pane. Find Files shows up 10 search result tabs while the tool is open, but does not maintain the results after you close the tool.

Function Alternative.   Use lookfor to search for the specified text in the first line of help for all M-files on the search path.


Previous page  Opening and Running Files Accessing Source Control Features Next page

© 1994-2005 The MathWorks, Inc.