/
getFileList

getFileList

Description

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.

Functional area

System

Command syntax

Syntax

getFileList "searchDirectory"[-recursive] [-pattern string] [-nameOnly] [-sort string string]

Arguments

NameTypeRequiredComments
searchDirectorystringyesThe directory to search for files in.

Flags

NameFlag argumentsArgument typeExclusive toComments
recursive0Searches for files in sub-directories of the specified directory. By default sub-directories are not searched.
pattern1stringSpecifies the file name pattern to match when searching for files. Default is to search for all files (".")
nameOnly0Specifies 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").
sort2stringSpecifies 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.

Return value

string array

Returns a string array with all of the files found.

Examples

// 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
    // ...
    // ...
  }

Additional information

Related commands