DirectoryList()
Lists the directory and returns the list of files under it as array or query
DirectoryList( path=string, recurse=boolean, listInfo=string, filter=any, sort=string, type=string );
Returns: any
Argument | Description |
---|---|
path
string,
required
|
The absolute path of the directory to list the content from. This can be any type of supported Virtual File Systems Alias: absolute_path, absolutePath |
recurse
boolean,
optional
|
Specifies whether to include subdirectories in the listing. If |
listInfo
string,
optional
|
Defines the return type of this function:
|
filter
any,
optional
|
Specifies a filter to be used to filter the results:
|
sort
string,
optional
|
Query columns by which to sort a directory listing. To use sort, "listInfo" must be set to "query"! Delimited list of columns from query output. Sorting is case sensitive. To qualify a column, use one of the following values:
|
type
string,
optional
|
type of the result returned:
|
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"); })
See also
- File handling
- DirectoryCopy()
- DirectoryCreate()
- DirectoryDelete()
- DirectoryExists()
- DirectoryRename()
- GetFileInfo()
- <cfdirectory>
- Search Issue Tracker
- Search Lucee Test Cases (good for further, detailed examples)