#ListDirR (recursive directory listing)
ts
function ListDirR(what, mask: string): DirListItem[];
The ListDirR
function lists the contents of a directory in the local file system, recursively incluiding the contents of all of its subdirectories, and returns the results in a JavaScript array of DirListItem objects.
This function accepts either 1 or 2 parameters:
Parameter | Type | Requirement | Explanation |
---|---|---|---|
what | string | required | must be a valid and existent directory on a local file system |
mask | string | optional | file-mask (example: *.docx) to limit the scope of the returned results only to items matching such mask; if this parameter is not specified, the list will include all files in the directory and all of its subdirectories |
Example
ts
{
// ...
// Acquire directory list
var dirList = cli.ListDirR('/docs');
// Log each item in the list
for (var i = 0; i < dirList.length; i++) {
Log(dirList[i].Name);
}
// ...
}
Example (with mask parameter)
ts
{
// ...
// Acquire directory list
var dirList = cli.ListDirR('/docs', '*.docx'); // only list *.docx files, including those in subfolders
// Log each item in the list
for (var i = 0; i < dirList.length; i++) {
Log(dirList[i].Name);
}
// ...
}