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 null means the site root, the same as in getFolders, listFiles and getFiles.

options (optional)objectSpecify any of the following options parameters:
searchPattern string

Wildcard for search, default is *.
If not specified, all folders will be returned.

recursive bool

Return folders from all subfolders also.
If not specified, default is "false".

includeCounters bool

Returns number of files in each folder.
If not specified, default is "false".

Returns

An array of folder objects carrying Id, Guid, Name, Created, Modified, Path and Count. The names differ from getFoldersId 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));
    }
}#