listFolders(path, [options])
The fastest function to retrieve a list of folders from a specific path.
Parameters
pathstringrequiredPath from which to list folders. An empty string or null means the site root, the same as in getFolders, listFiles and getFiles.
optionsobjectoptionalsearchPatternstringWildcard for the folder name, default is "*". abc*, *abc and *abc* work, and matching is not case sensitive.
recursiveboolReturn folders from all subfolders also.
If not specified, default is "false".
includeCountersboolReturns 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 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.
Folders whose name starts with # are never included, nor is anything below them, and neither are folders the site's publisher has no website (Visit) access to — the same rules as getFolders. Access is that of the user who published the site — the user the site runs as — not of the visitor, so the result is the same for everyone. To tailor a list to the signed-in visitor in an API script, check each item with allowVisit. Listing a # folder by its own path, such as listFolders("#"), still returns its subfolders. An unknown folder gives an empty array; a path containing .. or a backslash gives null.
Example
#{
/* 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));
}
}#