getFilenames(path, [options])
Returns the names of the files in a folder — a lighter alternative to listFiles when the names are all you need. Only the folder itself is read, not its subfolders.
Parameters
pathstringrequiredFolder path from the site root. An empty string means the site root.
optionsobjectoptionalsearchPatternstringWildcard for the file name, default "*". abc*, *abc and *abc* work, and matching is not case sensitive.
accessstringWhose access the list follows. Leave it out for the default: the signed-in visitor in an API script, the publisher everywhere else. 'publisher' lists with the publisher's access in an API script too — use it when your script checks permissions itself, for example looking up a record anywhere in the site and then deciding from its own user registry. It is the publisher's access, not everything: folders the publisher is denied, # folders and tool folders are still left out. Any other value throws an error.
Returns
An array of file names (strings), as they are stored in Docly. Folder properties files and index.* files are left out. An unknown folder, or a folder the user has no website (Visit) access to, gives an empty array; a path containing .. or a backslash gives null. Access is checked for the signed-in visitor in an API script (/API/), and for the user who published the site everywhere else — on a page, and in an API script nobody is signed in to. Pass access: 'publisher' to check access for the publisher in an API script too — for an app that lets Docly handle sign-in and decides permissions itself (see Let Docly handle login, you handle the permissions). A page is cached and shared by every visitor, so on a page the list is the same for everyone.
Example
// List the PDF files in a folder
let names = docly.getFilenames("/Documents", "*.pdf");
for (let name of names)
write(name + "\n");