Type/to search
Built-in Functions
Global
Log
Market
Trade
Account
Futures
Exchange
IO
Network
Storage
Threads
TA
Talib
OS
os
os.open
os.fgets
os.fputs
os.mmap
os.getRootDir
os.listFiles
os.exists
os.remove
os.mkdir
os.rmdir
os.rename
os.stat
os.exit
File
ListFilesResult
FileStat
Structures
Built-in Variables and Constants
Conventions
Exchanges

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

TypeDescription

ListFilesResult object

A ListFilesResult object: files is the array of matching file names and dirs the array of subdirectories of the current directory.

Arguments

NameTypeRequiredDescription

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).