FileSearches

More...

Functions

String
findFirstFile(string pattern, bool recurse)

Returns the first file in the directory system matching the given pattern.

String
findFirstFileMultiExpr(string pattern, bool recurse)

Returns the first file in the directory system matching the given patterns.

String
findNextFile(string pattern)

Returns the next file matching a search begun in findFirstFile().

String
findNextFileMultiExpr(string pattern)

Returns the next file matching a search begun in findFirstFileMultiExpr().

int
getFileCount(string pattern, bool recurse)

Returns the number of files in the directory tree that match the given patterns.

int
getFileCountMultiExpr(string pattern, bool recurse)

Returns the number of files in the directory tree that match the given patterns.

Detailed Description

Functions

findFirstFile(string pattern, bool recurse)

Returns the first file in the directory system matching the given pattern.

Use the corresponding findNextFile() to step through the results. If you're only interested in the number of files returned by the pattern match, use getFileCount().

This function differs from findFirstFileMultiExpr() in that it supports a single search pattern being passed in.

note:

You cannot run multiple simultaneous file system searches with these functions. Each call to findFirstFile() and findFirstFileMultiExpr() initiates a new search and renders a previous search invalid.

Parameters:
pattern

The path and file name pattern to match against.

recurse

If true, the search will exhaustively recurse into subdirectories of the given path and match the given filename pattern.

return:

The path of the first file matched by the search or an empty string if no matching file could be found.

// Execute all .cs files in a subdirectory and its subdirectories.
for( %file = findFirstFile( "subdirectory/*.cs" ); %file !$= ""; %file = findNextFile() )
   exec( %file );

findFirstFileMultiExpr(string pattern, bool recurse)

Returns the first file in the directory system matching the given patterns.

Use the corresponding findNextFileMultiExpr() to step through the results. If you're only interested in the number of files returned by the pattern match, use getFileCountMultiExpr().

This function differs from findFirstFile() in that it supports multiple search patterns to be passed in.

note:

You cannot run multiple simultaneous file system searches with these functions. Each call to findFirstFile() and findFirstFileMultiExpr() initiates a new search and renders a previous search invalid.

Parameters:
pattern

The path and file name pattern to match against, such as *.cs. Separate multiple patterns with TABs. For example: "*.cs" TAB "*.dso"

recurse

If true, the search will exhaustively recurse into subdirectories of the given path and match the given filename patterns.

return:

String of the first matching file path, or an empty string if no matching files were found.

// Find all DTS or Collada models
%filePatterns = "*.dts" TAB "*.dae";
%fullPath = findFirstFileMultiExpr( %filePatterns );
while ( %fullPath !$= "" )
{
   echo( %fullPath );
   %fullPath = findNextFileMultiExpr( %filePatterns );
}

findNextFile(string pattern)

Returns the next file matching a search begun in findFirstFile().

Parameters:

pattern

The path and file name pattern to match against. This is optional and may be left out as it is not used by the code. It is here for legacy reasons.

return:

The path of the next filename matched by the search or an empty string if no more files match.

// Execute all .cs files in a subdirectory and its subdirectories.
for( %file = findFirstFile( "subdirectory/*.cs" ); %file !$= ""; %file = findNextFile() )
   exec( %file );

findNextFileMultiExpr(string pattern)

Returns the next file matching a search begun in findFirstFileMultiExpr().

Parameters:

pattern

The path and file name pattern to match against. This is optional and may be left out as it is not used by the code. It is here for legacy reasons.

return:

String of the next matching file path, or an empty string if no matching files were found.

// Find all DTS or Collada models
%filePatterns = "*.dts" TAB "*.dae";
%fullPath = findFirstFileMultiExpr( %filePatterns );
while ( %fullPath !$= "" )
{
   echo( %fullPath );
   %fullPath = findNextFileMultiExpr( %filePatterns );
}

getFileCount(string pattern, bool recurse)

Returns the number of files in the directory tree that match the given patterns.

This function differs from getFileCountMultiExpr() in that it supports a single search pattern being passed in.

If you're interested in a list of files that match the given pattern and not just the number of files, use findFirstFile() and findNextFile().

Parameters:

pattern

The path and file name pattern to match against.

recurse

If true, the search will exhaustively recurse into subdirectories of the given path and match the given filename pattern counting files in subdirectories.

return:

Number of files located using the pattern

// Count the number of .cs files in a subdirectory and its subdirectories.
getFileCount( "subdirectory/*.cs" );

getFileCountMultiExpr(string pattern, bool recurse)

Returns the number of files in the directory tree that match the given patterns.

If you're interested in a list of files that match the given patterns and not just the number of files, use findFirstFileMultiExpr() and findNextFileMultiExpr().

Parameters:

pattern

The path and file name pattern to match against, such as *.cs. Separate multiple patterns with TABs. For example: "*.cs" TAB "*.dso"

recurse

If true, the search will exhaustively recurse into subdirectories of the given path and match the given filename pattern.

return:

Number of files located using the patterns

// Count all DTS or Collada models
%filePatterns = "*.dts" TAB "*.dae";
echo( "Nunmer of shape files:" SPC getFileCountMultiExpr( %filePatterns ) );