ListDir (list a directory)
ts
function ListDir(what: string, mask?: string): DirListItem[];Lists the contents of a directory in the local file system and returns a JavaScript array of DirListItem objects.
| Parameter | Type | Requirement | Explanation |
|---|---|---|---|
what | string | required | Path to a valid, existing directory in the local file system |
mask | string | optional | File mask (e.g., *.docx) to filter results; if omitted, all files are listed |
Example
ts
// Acquire directory list
var dirList = cli.ListDir('/docs');
if (Array.isArray(dirList)) {
dirList.forEach(function(item) {
Log(item.Name);
});
}Example (with mask parameter)
ts
// Acquire directory list with mask
var dirList = cli.ListDir('/docs', '*.docx'); // only list *.docx files
if (Array.isArray(dirList)) {
dirList.forEach(function(item) {
Log(item.Name);
});
}