Version: 3
restore

Contents

Method

GetFilesInFolder

ModuleFileSystem
LibraryCore
Action

Returns the filename, size, created time and modified time of each file in a folder.

Parameters

Folder (string): The folder whose contents will be returned

Recursive (boolean; optional, default true): Whether or not to return the contents of subfolders.

Return values

If Folder is an empty string then an InvalidParameter error is returned along with the following string:

    • Folder parameter should not be empty

If Folder does not exist then an ExecutionError status is returned along with the following string:

    • Folder '<folder>' does not exist
If Folder is actually a file then an ExecutionError status is returned along with the following string:
    • Folder '<Folder>' is not a folder

If Folder itself cannot be opened (exceptions will be logged by the agent) or no files are found then this is considered a successful execution but no results are returned.

If Folder itself can be opened and Recursive is true but then a sub folder or file cannot be accessed then those items will be skipped in the results (the agent will log warnings).

Otherwise if any files are found then the result returned will have this form:

    • FileName (string): The full path of the file
    • FileSize (int): The size of the file in bytes
    • DateCreated (string): The creation date of the file
    • DateModified (string): The last modified date of the file
Example
 FileSystem.GetFilesInFolder(Folder:"c:\\tmp");
 FileSystem.GetFilesInFolder(Folder:"c:\\tmp", Recursive:false);
Platforms
  • Windows
  • Linux
  • MacOS
  • Solaris Intel
  • Solaris Sparc
  • Android
Notes

The DateCreated concept does not exist on some operating systems and consequently this field will be blank where it does not apply.

Where the agent cannot access Folder itself then the instruction will return ExcutionError