findFiles
R2026bSyntax
Description
lists all project files and folders in the project projectFiles = findFiles(proj)proj.
filters the files projectFiles = findFiles(proj,files)files and returns only the files that are
project files.
specifies additional options as one or more name-value arguments. Use this syntax to
find files in a project using their label, to include referenced projects in the
search, and more.projectFiles = findFiles(___,Name=Value)
Examples
Open the Times Table App project. Use currentProject
to create a project object from the currently loaded project.
openExample("matlab/TimesTableProjectExample")
proj = currentProject;List all files that are part of the project.
testFiles = findFiles(proj);
Open the Times Table App project. Use currentProject
to create a project object from the currently loaded project.
openExample("matlab/TimesTableProjectExample")
proj = currentProject;Create an array of the files you want to query.
fileInProject = fullfile("source","timestable.mlapp"); fileOutsideProject = fullfile("..","TimesTableProjectExample.m"); files = [fileInProject;fileOutsideProject]
files =
2×1 string array
"source\timestable.mlapp"
"..\TimesTableProjectExample.m"
Find which files are project files.
projectFiles = findFiles(proj,files)
files =
1×1 string array
"C:\Users\username\Documents\TimesTableProjectExample\TimesTableApp\source\timestable.mlapp"
To query the project file properties such as source control status and
revision ID, create a ProjectFile object instead.
projectFiles = findFiles(proj,files,OutputFormat="ProjectFile") ProjectFile with properties:
Path: "C:\Users\username\Documents\TimesTableProjectExample\TimesTableApp\source\timestable.mlapp"
Revision: "00ef792a696a10b62db2b2951efbab4ecbae6610"
SourceControlStatus: Unmodified
Labels: [1×1 matlab.project.Label]
Open the Times Table App project. Use currentProject
to create a project object from the currently loaded project.
openExample("matlab/TimesTableProjectExample")
proj = currentProject;Create a test suite from all project files labeled
Test.
testFiles = findFiles(proj,Label="Test");If the project has more than one category with the label
Test, specify the category name. For example,
testFiles =
findFiles(proj,Category="Classification",Label="Test");
Open the top-level project in your hierarchy and create a project object.
proj = openProject('C:/projects/TopLevelProject');Find all files labeled Design in your project
hierarchy, including the referenced projects.
allDesignFiles = findFiles(proj,Label="Design",IncludeReferences=true);Input Arguments
Project, specified as a matlab.project.Project object. Use currentProject to create a project object from the currently
loaded project.
Path of the files to filter, specified as a string array or a cell array of character vectors. When you specify files that include files outside of the project root folder or that are not part of the project, the function returns only the files that are project files.
To match files and folders more efficiently, you can specify glob patterns. This function supports these glob patterns: (since R2026b)
*— Match any characters within a single folder (nonrecursive wildcard).**— Match files and folders recursively.!— Exclude matches using a negation prefix./— Match directories only when used as a trailing slash.
For more information about pattern matching, see Match Files and Folders Using Patterns.
Name-Value Arguments
Specify optional pairs of arguments as
Name1=Value1,...,NameN=ValueN, where Name is
the argument name and Value is the corresponding value.
Name-value arguments must appear after other arguments, but the order of the
pairs does not matter.
Example: findFiles(proj,Label="Test",IncludeReferences=true,OutputFormat="ProjectFile")
Name of the category of labels, specified as a character vector or string scalar.
If you specify only the category name without the label name, the function returns all files that have labels from the specified category.
If you have more than one category in your project with same label names, specify both the category name and the label name.
Data Types: char | string
Name of the label, specified as a character vector or string scalar.
If you specify only the category name without the label name, the function returns all files that have labels from the specified category.
If you have more than one category in your project with same label names, specify both the category name and the label name.
Data Types: char | string
Option to include the referenced projects in the search, specified as
a numeric or logical 1 (true) or 0
(false).
Data Types: logical
Option to choose the format of the output, specified as
"string" or "ProjectFile". Use
the "ProjectFile" format if you require information
about the file such as the source control status and revision ID.
Output Arguments
Project files, returned as a string array or a
ProjectFile object, depending on the value you
specify for OutputFormat.
Version History
Introduced in R2024aYou can now find files more efficiently by using these glob patterns:
*— Match any characters within a single folder (nonrecursive wildcard)**— Match files and folders recursively!— Exclude matches using a negation prefix/— Match directories only when used as a trailing slash
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)