LISTFILES function

Synopsis
This function returns the names of files and/or folders present in the specified folder, and optionally in its subfolders.
Remarks
Variations
LISTFILES(Path)
Returns the names of files in the specified folder.
Parameters
Path

Specifies the path to the folder.

Supported types: String.
Returns
Returned types: String array.
Examples
1.

The following example returns all files, in the SavedImages subfolder of the DA Documents folder, with their full name. Specifically, on a Matrox Iris GTR, if the folder contains 2 files, LISTFILES returns the string array listed in the table below.

LISTFILES(CONCAT(PATH("DA Documents"),"\\SavedImages"))

Index

String returned

1

/home/mtxuser/Documents/Matrox Design Assistant/SavedImages/ThisImage.bmp

2

/home/mtxuser/Documents/Matrox Design Assistant/SavedImages/ThatImage.bmp

2.

The following example returns all files, in the folder C:\Temp\, with their full name. Specifically, on a PC runtime platform, if the folder contains 2 files, LISTFILES returns the string array listed in the table below.

LISTFILES("C:\\Temp\\")

Index

String returned

1

C:\Temp\ThisFile.txt

2

C:\Temp\ThatFile.txt

3.

The following example returns all files, in the network folder \\MYMACHINE\ResultsArchive, with their full name. Specifically, on a PC runtime platform, if the folder contains 2 files, LISTFILES returns the string array listed in the table below.

LISTFILES("\\\\MYMACHINE\\ResultsArchive")

Index

String returned

1

\\MYMACHINE\ResultsArchive\ThisImage.bmp

2

\\MYMACHINE\ResultsArchive\ThatImage.bmp

LISTFILES(Path, SearchPattern)
Returns the names of files in the specified folder, matching the given search pattern.
Parameters
Path

Specifies the path to the folder.

Supported types: String.
SearchPattern

Specifies the search string to match against the names of files in the path. This parameter can contain a combination of a valid literal path and wild card characters (* and ?), but does not support regular expressions.

Supported types: String.
Returns
Returned types: String array.
Examples
1.

The following example returns all files, in the SavedImages subfolder of the DA Documents folder, that have the extension .jpg.

LISTFILES(CONCAT(PATH("DA Documents"), "\\SavedImages"), "*.jpg")
2.

The following example returns all files, in the network folder \\MYMACHINE\ResultsArchive, that have a name containing the word "ARCHIVED".

LISTFILES("\\\\MYMACHINE\\ResultsArchive", "*ARCHIVED*")
LISTFILES(Path, SearchMode)
Returns the names of the files in the specified folder, and uses the specified search mode to modify the search.
Parameters
Path

Specifies the path to the folder.

Supported types: String.
SearchMode

Specifies the search mode. You can specify one or more of the following options. To specify more than one option, use the "|" symbol.

Value Description
Files

Lists the name of files and their location. This value is used by default and can be used in combination with Folders (Folders | Files).

(summarize)
Folders

Lists the folders. This value cannot be used with SortByExt or SortBySize.

(summarize)
Recursive

Lists the outcome of a search that includes the specified folder and all its subfolders.

Reverse

Lists the outcome of the search in opposite order (from last to first).

ShortNames

Lists the names of the files or folders without their full path.

SortByExt

Lists files sorted by their extension.

SortByName

Lists all entries sorted by their short name.

SortBySize

Lists all entries sorted by size.

SortByTime

Lists all entries sorted by their last modified date.

Supported types: String.
Returns
Returned types: String array.
Examples
1.

The following example returns all files, in the DA Documents folder and fully recursively through its subfolders. The files are sorted by size and are listed only by file name (the full file path is omitted).

LISTFILES(PATH("DA Documents"), SortBySize | Recursive | ShortNames)
LISTFILES(Path, SearchPattern, SearchMode)
Returns the names of the files in the specified folder, matching the given search pattern, and uses the specified search mode to modify the search.
Parameters
Path

Specifies the path to the folder.

Supported types: String.
SearchPattern

Specifies the search string to match against the names of files in the path. This parameter can contain a combination of a valid literal path and wild card characters (* and ?), but does not support regular expressions.

Supported types: String.
SearchMode

Specifies the search mode. You can specify one or more of the following options. To specify more than one option, use the "|" symbol.

Value Description
Files

Lists the name of files and their location. This value is used by default and can be used in combination with Folders (Folders | Files).

(summarize)
Folders

Lists the folders. This value cannot be used with SortByExt or SortBySize.

(summarize)
Recursive

Lists the outcome of a search that includes the specified folder and all its subfolders.

Reverse

Lists the outcome of the search in opposite order (from last to first).

ShortNames

Lists the names of the files or folders without their full path.

SortByExt

Lists files sorted by their extension.

SortByName

Lists all entries sorted by their short name.

SortBySize

Lists all entries sorted by size.

SortByTime

Lists all entries sorted by their last modified date.

Supported types: String.
Returns
Returned types: String array.
Examples
1.

The following example returns all files and subfolders in the DA Documents folder. This includes all subfolders and the files they contain. The folders will be listed at the beginning of the returned array, sorted alphabetically by their short name. This will be followed by the files, also sorted by their short name.

LISTFILES(PATH("DA Documents"), "*", Recursive | SortByName | Folders | Files)
LISTFILES(Path, SearchPattern, SearchMode, Limit)
Returns the names of files in the specified folder, matching the given search pattern. It uses the specified search mode to modify the search, and restricts the results shown to the specified limit.
Parameters
Path

Specifies the path to the folder.

Supported types: String.
SearchPattern

Specifies the search string to match against the names of files in the path. This parameter can contain a combination of a valid literal path and wild card characters (* and ?), but does not support regular expressions.

Supported types: String.
SearchMode

Specifies the search mode. You can specify one or more of the following options. To specify more than one option, use the "|" symbol.

Value Description
Files

Lists the name of files and their location. This value is used by default and can be used in combination with Folders (Folders | Files).

(summarize)
Folders

Lists the folders. This value cannot be used with SortByExt or SortBySize.

(summarize)
Recursive

Lists the outcome of a search that includes the specified folder and all its subfolders.

Reverse

Lists the outcome of the search in opposite order (from last to first).

ShortNames

Lists the names of the files or folders without their full path.

SortByExt

Lists files sorted by their extension.

SortByName

Lists all entries sorted by their short name.

SortBySize

Lists all entries sorted by size.

SortByTime

Lists all entries sorted by their last modified date.

These values can also be used in combination with the above values; however, in this case, you must specify a value for the Limit parameter:

Value Description
CumulativeSize

Lists only the files whose cumulative size is less than Limit (in Mbytes). Note that any sorting operations are done before calculating the cumulative size; therefore, the results will be dependent on the values for SearchMode that you choose.

(summarize)
ExceedingAge

Lists only the files that are older than Limit (in sec).

ExceedingCount

Lists only the files that are more than Limit (number of files). Note that any sorting operations are done before calculating which files exceed the count; therefore, the results will be dependent on the values for SearchMode that you choose.

(summarize)
ExceedingCumulativeSize

Lists only the files whose cumulative size is more than Limit (in Mbytes). Note that any sorting operations are done before calculating the cumulative size; therefore, the results will be dependent on the values for SearchMode that you choose.

(summarize)
ExceedingSize

Lists only the files that have a size greater than Limit (in Mbytes).

Supported types: String.
Limit

Specifies the numeric limit of the Exceeding values of SearchMode. The possible values for this parameter are explained in the description of the previous parameter.

Supported types: Numeric.
Returns
Returned types: String array.
Examples
1.

The following example returns all files, in the SavedImages subfolder of the DA Documents folder, that are older than the last 24 hours (60 sec * 60 min * 24 hour). The files are sorted with the newest files first.

LISTFILES(CONCAT(PATH("DA Documents"), "\\SavedImages"), "*", SortByTime | ExceedingAge, 60*60*24)
2.

The following example returns all files, in the SavedTextFiles subfolder of the DA Documents folder, with a size greater than 20 Mbytes.

LISTFILES(CONCAT(PATH("DA Documents"), "\\SavedTextFiles"), "*", ExceedingSize, 2)
3.

The following example returns all files, in the SavedImages subfolder of the DA Documents folder, excepting the first 50 Mbytes of files starting with the newest. Note that the ExceedingCumulativeSize setting is calculated after any sort settings have been applied.

LISTFILES(CONCAT(PATH("DA Documents"), "\\SavedImages"), "*", SortByTime | ExceedingCumulativeSize, 50)
4.

The following example returns the oldest files, in the SavedImages subfolder of the DA Documents folder, except for the newest 5. Note that the ExceedingCount setting is calculated after any sort settings have been applied. The example sorts the returned list by time and reverses the output order; therefore, the oldest files are listed first. If there were only 6 files in this location, our example would simply return the oldest file.

LISTFILES(CONCAT(PATH("DA Documents"), "\\SavedImages"), "*", SortByTime | Reverse | ExceedingCount, 5)
5.

The following example returns all files, in the D:\TestImages\SecondPhase folder, that are older than the last 24 hours (60 sec * 60 min * 24 hour). The files are sorted with the newest files first.

LISTFILES("D:\\TestImages\\SecondPhase", "*", SortByTime | ExceedingAge, 60*60*24)