FindFiles
The FindFiles function opens a folder and finds all file names matching a file name template. The file names are returned in a Lua table. This function uses the CFindFiles class internally, but does not expose a CFindFiles object to the script.
tFileNames = FindFiles( sFolder ) tFileNames = FindFiles( sFolder, sTemplate ) where sFolder is the name of the folder to be searched. sTemplate is an optional wildcard template for file names to be found tFileNames is the returned table containing all the files that were found. On failure, nil is returned. |
This method returns a Lua table containing all files that were found using the path and file name template. You can iterate over this table using the ipairs iterator as shown in the Example, below, or you can access each file name as a table element, like tFileNames[1] or tFileNames[12]. To get the number of files found, use the table.getn library function, as in table.getn( sFileNames ).
The following script lists all files inside the folder sFolder using the file name template "*.fts"
|
-- find all the files |
|
-- check if any files were found |
|
-- iterate through the table |
|
-- print the k-th file name |
|
|
|
|