getFiles(path, [options]) Last updated: 03. Dec 2025

Gets a list of files from folder / optionally recursively from subfolders.

Parameters

Name Type Description
path string Absolute path to folder (from site root)
options (optional)objectSpecify any of the following options parameters:
name string Filename wildcard (e.g. "*.pdf"), default is "*"
depth number Subfolder levels to traverse, default is 0.
mode enum Detail level: "Full", "Medium" (default), "Min"
schema string Schema name wildcard, default is "*"
recursive boolean Include files from all subfolders.
search string Search query using the built-in search engine. Only returns files matching the search criteria. Searches filenames, tags, and indexed fields. Accepts search query as string (e.g. "annual report").
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.MyProperty == "myValue")
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"})

Returns

An array of files.

Example

Code example (#JS)

#JS is mixed HTML (or other text file) with inline JavaScript with # starting and ending each inline statement.
#{
    // Get files from folder
    let files = docly.getFiles("/Test files");
    
    // Get first item of array
    let first = files[0];
    
    // Convert object to JSON string
    let json = JSON.stringify(first);

    // Format indent and line breaks in JSON
    let pretty = docly.formatJson(json);
    
    // Remove empty lines
    let html = pretty.replace(chr(13), "");
    
}#

<b>Information about first file:</b>
#html#

Output

The #JS code above produces the output shown below:

<b>Information about first file:</b>
{
  "Notat": "Just a test",
  "Notater": [],
  "Notater_type": "Notater",
  "Bilder": [],
  "Bilder_type": "Bilder",
  "Vedlegg": [],
  "Vedlegg_type": "Vedlegg",
  "Title": "Testfile",
  "opendoc": "https://docly.net/#D4v7vTawTlkOk8n9EsV22tA?backurl=https%3a%2f%2fdevelopers.docly.net%2fJavaScript%2fFilesystem-functions%2fgetFiles",
  "Url": "/Test-files/Testfile",
  "FormName": "Notat",
  "DoclyTypeId": 1,
  "DoclyTimestamp": "638070494826662191",
  "Tags": [],
  "LastModifiedBy": "r@dops.no",
  "folderpath": "/Test files",
  "filename": "Testfile",
  "filepath": "/Test files/Testfile",
  "fileschema": "Notat",
  "file": true,
  "Guid": "4v7vTawTlkOk8n9EsV22tA",
  "CreatedTime": "2022-12-19T12:24:42.5920399+01:00",
  "LastModified": "2022-12-19T12:24:42.6662191+01:00",
  "Filesize": 376
}