findFiles - Find project files by category or label name - MATLAB (original) (raw)
Find project files by category or label name
Since R2024a
Syntax
Description
[projectFiles](#mw%5Fff25d98e-53ba-47da-82f7-5480b12b368c) = findFiles([proj](#mw%5F77654c4092d60-9abd-4430-94f3-f229b5f627da%5Fsep%5Fmw%5F67855d3a-5501-4c51-aab0-b8f7aeb42e61))
lists all project files and folders in the project proj
.
[projectFiles](#mw%5Fff25d98e-53ba-47da-82f7-5480b12b368c) = findFiles([proj](#mw%5F77654c4092d60-9abd-4430-94f3-f229b5f627da%5Fsep%5Fmw%5F67855d3a-5501-4c51-aab0-b8f7aeb42e61),[files](#mw%5Ffa9e4d7a-aba3-4e8f-af5e-1926e474b55b))
filters the files files
and returns only the files that are project files.
[projectFiles](#mw%5Fff25d98e-53ba-47da-82f7-5480b12b368c) = findFiles(___,[Name=Value](#namevaluepairarguments))
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.
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 labeledTest
.
testFiles = findFiles(proj,Label="Test");
If the project has more than one category with the labelTest
, 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.
Name-Value Arguments
Specify optional pairs of arguments asName1=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 aProjectFile
object, depending on the value you specify for OutputFormat.
Version History
Introduced in R2024a