DirectoryList

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

Returns: any

Usage

DirectoryList( path [, recurse [, listInfo [, filter [, sort [, type ] ] ] ] ] )

Arguments

Argument Description
path
(string, required)

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, optional)

Whether Lucee performs the action on subdirectories: If true, contents of all subdirectories are also listed.

listInfo
(string, optional)

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, optional)

Filter to be used to filter the results: * A string that uses "*" as a wildcard, for example, "*.cfm" * a UDF (User defined Function) with signature Boolean function(String path). The function is run for each file in turn; if the function returns true, then the file is will be added to the result; otherwise it will be omitted.

sort
(string, optional)

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.

type
(string, optional)

type of the result returned: - file: includes only filenames - dir: includes only directory names - all: includes both filenames and directory names

Examples

To return an array of file paths that end with the substring .log from a the directory /var/data:

directoryList("/var/data", false, "path", function(path){ return arguments.path.hasSuffix(".log"); })