getFolders(path, [options]) Last updated: 16. Aug 2026

Gets a list of all subfolders below a specific folder.

See also: listFolders getFolder getFiles GetFiles and Folders - examples List folders (for) Path traversal

Parameters

Name Type Description
path string

Absolute path to the folder which you want to list sub folders for.

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

Enter a wildcard of folders to retrieve, default is "*"

depth number

How many extra levels of subfolders, default is 0

recursive bool

Get sub folders recursively, default false.

properties bool

Get with folder properties, default true.
Use false for faster execution without this extra information.

filter object | function

Filter items based on their properties. Accepts either:

  1. Object with key-value pairs for exact matching (e.g. { "Status": "active", "Category": "docs" })
  2. Function that receives each file and returns true/false (e.g. x => x.Filesize > 1000 && x.Extension == "pdf")
fields csv | array | object

Specify fields to retrieve via:

  1. CSV string (e.g. "filename,Filesize")
  2. Array of strings (e.g. ["filename","Filesize"])
  3. Object map for renaming (e.g. {"newName":"filename"})
includeCounters bool

Add a Count field to each folder with the number of documents it contains, default false. Deleted documents and the folder properties file are not counted. Returns the same number as listFolders.

Returns

An array of folder objects. Every object carries Name, Url, Path, DoclyId, Guid, Created, LastModified and Size — the same names and date form getFolder uses for the fields they share. Count is added only when includeCounters is true. Unless you pass properties: false, the folder's own fields from its folder document are merged in first, so a custom field sharing one of the standard names above is overwritten by the standard value; Count is the exception and is left alone unless you ask for counters.

Example

Code example (#JS)

#JS is mixed HTML (or other text file) with inline JavaScript with # starting and ending each inline statement.
#{
    // Get the list of files
    var list = docly.getFolders("Test files");
    
    // The rest of the code just outputs the list in the demo field below
    var json = JSON.stringify(list);
    var formatted = docly.formatJson(json);
    var html = formatted.replace(chr(13), "");
    write(html);
}#

Output

The #JS code above produces the output shown below:
[
  {
    "SortOrder": "1",
    "DefaultContent": true,
    "Accept": "",
    "SpecifyCustomColumns": false,
    "CustomColumns": [],
    "CustomColumns_type": "CustomColumns",
    "HideFilenameColumn": false,
    "Expand": true,
    "Packages": [],
    "Packages_type": "Packages",
    "ROWID": "4533b73f-c3b6-5e77-b143-222e43d122fb",
    "OKCount": "0",
    "PassedCount": "0",
    "FailedCount": "0",
    "TotalCount": "0",
    "RemainCount": "0",
    "Name": "Folder 1",
    "Url": "/Test-files/Folder-1",
    "DoclyId": 45972,
    "Guid": "3rujvHyLOE-BkiQUUX5Kng",
    "LastModified": "2025-01-30T11:16:35.500075+01:00",
    "Created": "2022-12-21T11:43:22.6787745+01:00",
    "Size": 573,
    "Path": "/Test files/Folder 1"
  },
  {
    "Name": "Folder 2",
    "Url": "/Test-files/Folder-2",
    "DoclyId": 45973,
    "Guid": "4KBt5OiHKUO_CMfMjN4rUA",
    "LastModified": "2025-01-30T11:15:36.4144002+01:00",
    "Created": "2022-12-21T11:43:25.408145+01:00",
    "Size": 228,
    "Path": "/Test files/Folder 2"
  },
  {
    "Name": "Folder 3",
    "Url": "/Test-files/Folder-3",
    "DoclyId": 45974,
    "Guid": "rXOvQs861068dtNVyXh3nQ",
    "LastModified": "2025-01-30T11:15:41.7160163+01:00",
    "Created": "2022-12-21T11:43:27.6845512+01:00",
    "Size": 228,
    "Path": "/Test files/Folder 3"
  }
]