GetFiles(path, [searchPattern], [depth], [mode]) Last updated: 16. May 2023
Gets a list of files from folder / optionally recursively from subfolders.
Parameters
Name | Type | Description |
---|---|---|
path | string | Absolute path to folder (from site root) |
searchPattern (optional) | string | Enter a wildcard of files to retreive, default is "*" |
depth (optional) | number | How many extra levels of subfolders, default is 0 |
mode (optional) | enum | How much information to retreive for each item: Full = All properties (slowest) Medium = A lot of properties (OK speed) Min = Minimum (fastest) "Medium" is default. |
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
var files = docly.getFiles("/Test files");
// Get first item of array
var first = docly.first(files);
// Convert object to JSON string
var json = JSON.stringify(first);
// Format indent and line breaks in JSON
var pretty = docly.formatJSON(json);
// Remove empty lines
var 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",
"Tags": [],
"opendoc": "https://docly.net/#D4v7vTawTlkOk8n9EsV22tA?backurl=https%3a%2f%2fdevelopers.docly.net%2fJavaScript%2fFilesystem-functions%2fGetFiles",
"Title": null,
"Url": "/Test-files/Testfile",
"FormName": "Notat",
"DoclyTypeId": 1,
"DoclyType": "Document",
"LastModifiedBy": "r@dops.no",
"folderpath": "/Test files",
"filename": "Testfile",
"file": true,
"DoclyId": 167526,
"Guid": "4v7vTawTlkOk8n9EsV22tA",
"FormId": 688,
"CreatedTime": "2022-12-19T12:24:42.5920399+01:00",
"LastModified": "2022-12-19T12:24:42.6662191+01:00",
"Filesize": 376
}