listFolders(path, [options]) Last updated: 16. Aug 2026
The fastest function to retrieve a list of folders from a specific path.
See also: getFolders listFiles GetFiles and Folders - examples List folders (for) Path traversal
Parameters
| Name | Type | Description |
|---|---|---|
| path | string | Path from which to list folders. An empty string or |
| options (optional) | object | Specify any of the following options parameters: |
| • searchPattern | string | Wildcard for search, default is *. |
| • recursive | bool | Return folders from all subfolders also. |
| • includeCounters | bool | Returns number of files in each folder. |
Returns
An array of folder objects carrying Id, Guid, Name, Created, Modified, Path and Count. The names differ from getFolders — Id rather than DoclyId, Modified rather than LastModified — and there is no Url or Size. Path is relative to the folder you asked for, and is null unless recursive is true. Count is 0 unless includeCounters is true.
Example
Code example (#JS)
#JS is mixed HTML (or other text file) with inline JavaScript with # starting and ending each inline statement.#{
/* Get all folders starting with "example" */
let folders = docly.listFolders("/Test files", { searchPattern: "example*" });
/* List all folders */
for(let folder of folders)
{
var json = JSON.stringify(folder);
var html = JSON.format(json).replace(chr(13), "");
write(html);
write(chr(13) + "-----------------------------" + chr(13));
}
}#