os.listFiles
List files and subdirectories in the specified directory.
listFiles()
listFiles(pattern)Examples
List matched files and directories.
javascript
function main() {
// list all json files
let result = os.listFiles("*.json")
Log("result:", result)
// list everything
let allFiles = os.listFiles()
Log("allFiles:", allFiles)
}Returns
| Type | Description |
| A |
Arguments
| Name | Type | Required | Description |
pattern | string | No | Optional matching pattern, supports wildcards (e.g., .txt, data_.json), can specify directory path. |
See Also
Remarks
When the pattern parameter is not specified, lists all files and subdirectories in the file root directory (the directory returned by getRootDir). When pattern is a directory path, that directory is listed; wildcards (*, ?) are only allowed in the last path segment, e.g. data/*.json, and the returned names then carry the directory prefix (e.g. data/a.json).