findFiles
Syntax
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
List All Project Files
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);
Find Files and Examine Properties
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]
Create Test Suite Using Project Labels
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");
Find Files in Project and References
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
proj
— Project
matlab.project.Project
object
Project, specified as a matlab.project.Project
object.
Use currentProject
to create a project object from the currently
loaded project.
files
— Path of files
string array | cell array of character vectors | array of ProjectFile
objects
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.
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")
Category
— Name of category
character vector | string scalar | Category
object
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
Label
— Name of label
character vector | string scalar | LabelDefinition
object
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
IncludeReferences
— Option to include referenced projects
false or 0
(default) | true or 1
Option to include the referenced projects in the search, specified as
a numeric or logical 1
(true) or 0
(false).
Data Types: logical
OutputFormat
— Output format
"string"
(default) | "ProjectFile"
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
projectFiles
— Project files
string array (default) | ProjectFile
object
Project files, returned as a string array or a
ProjectFile
object, depending on the value you
specify for OutputFormat
.
Version History
Introduced in R2024a
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)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)