Returns the list of files in the specified directory.
Can optionally search through all sub-directories, as well as only retrieve file names matching a certain pattern.
System
getFileList "searchDirectory"[-recursive] [-pattern string] [-nameOnly] [-sort string string] |
Name | Type | Required | Comments |
---|---|---|---|
searchDirectory | string | yes | The directory to search for files in. |
Name | Flag arguments | Argument type | Exclusive to | Comments |
---|---|---|---|---|
recursive | 0 | — | — | Searches for files in sub-directories of the specified directory. By default sub-directories are not searched. |
pattern | 1 | string | — | Specifies the file name pattern to match when searching for files. Default is to search for all files (".") |
nameOnly | 0 | — | — | Specifies that only the file name portion (including extension) be returned instead of the full file path (e.g. return "MyFile.hdf" for "C:/Data/MyFile.hdf"). |
sort | 2 | string | — | Specifies that the returned file list be sorted according to the given criteria. The first argument can be either "name", "path", "size", "created", "modified", and "accessed". The second argument can be either "asc" or "desc" for ascending and descending, respectively. By default the files are returned in the order in which they are encountered. |
string array
Returns a string array with all of the files found.
// Get list of files in a directory. int $i, $count; string $path = "c:/data/day/"; string $files[]; // Get all the c3d files in the directory $files = `getFileList $path -pattern "*.c3d"`; // Get the number of files returned $count = `getCount $files`; // Operate on each file for( $i = 0; $i < $count; $i += 1 ) { // Do something with the file // ... // ... } |