getFiles(path, [options]) Last updated: 17. Aug 2026

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

See also: getFile listFiles getFolder getFolders GetFiles and Folders - examples List folders (for) getTags addTag getAllTags Path traversal

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" or "Json". Omitting the parameter — or passing null — gives "Medium".

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"})
tag string

Only return files carrying this tag. The value is normalized exactly as tags are when they are stored, so "Invoice" finds the stored tag invoice. A value of several words requires all of them, and a value that normalizes to nothing (a single character, punctuation only) returns an empty result rather than everything. Filtering happens in the database, not on the returned array — unlike search, which runs the full text search engine, tag is an exact match against the document's tags. See addTag.

tags bool

Include a Tags array with each file, default false. Use this instead of mode "Full" when tags are all you need — it adds the tag join without the rest of the Full detail level. Not to be confused with tag (string), which filters on a tag instead of returning them.

Returns

An array of file objects.

Each object is the document's own fields with Docly's file metadata merged in, so your schema's field names appear alongside the ones below. Docly writes its metadata last, so a field of yours that shares a name with one of them is overwritten — the one exception is Title, where your own value wins. Which metadata you get depends on mode.

Always present, from "Min" and up:

Field Description
filename File name, extension trimmed
filepath Path from the site root, with .hash/.html trimmed. null in "Min"
fileschema Schema name, null for a schemaless file
file Always true — lets you tell files from folders in a mixed list
Guid The document's id
CreatedTime When the file was created
LastModified When the file was last changed
Filesize Size in bytes

"Medium" adds — this is the default:

Field Description
folderpath Path to the containing folder, with no trailing slash. null for a file at the site root
Url filepath, URL-encoded
Title The document's own Title if it has one, otherwise the file name
FormName Schema name
DoclyTypeId Document type id
DoclyTimestamp LastModified as ticks — useful as a cache key or change check
opendoc Link that opens the document in the Docly workspace

"Medium" is also where filepath gets a value; in "Min" it is null.

"Full" adds:

Field Description
Tags Array of the document's tags
LastModifiedBy Email of the user who last changed the file

Tags costs a database join, which is why it is not in the default. If tags are all you need, keep "Medium" and pass tags: true instead of stepping up to "Full".

"Json" returns a different, flatter shape — a database record rather than the merged document:

Field Description
Id Internal numeric id
Guid The document's id
Name File name, extension included
Values The document's stored values, as raw JSON
Modified When the file was last changed
Schema Schema name, null for a schemaless file
ModifiedBy Email of the user who last changed the file
Path Always null from getFiles

Use "Json" when you want to pass the values on untouched; the document's fields are inside Values rather than on the object itself.

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",
  "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": 359
}