Tags · Functions · Objects
Lucee Function Reference
Choose a function:

Function DIRECTORYLIST

Lists the directory and returns the list of files under it as array or query

Example

directorylist(string path,[boolean recurse,[string listInfo,[any filter,[string sort]]]]):any

Arguments

The arguments for this function are set. You can not use other arguments except the following ones.
Name Type Required Description
path string  Yes The absolute path of the directory for which to list the contents. Alternatively, you can specify IP address as in the following example: DirectoryList(\"//12.3.123.123/c_drive/test\");.  
recurse boolean  No Whether Lucee performs the action on subdirectories: If true, contents of all subdirectories are also listed.  
listInfo string  No name: returns an array of names of files and directories.
path: returns an array of paths of files and directories.
query: returns a query.  
filter any  No Filter to be used to filter the results:
  • A string that uses "*" as a wildcard, for example, "*.cfm"
  • a UDF (User defined Function) using the following pattern "functioname(String path):boolean", the function is run for every single file, if the function returns true, then the file is will be added to the list otherwise it will be omitted  
  • sort string  No Query columns by which to sort a directory listing. Delimited list of columns from query output.
    To qualify a column, use one of the following values:
    asc: ascending (a to z) sort order.
    dec: descending (z to a) sort order.