Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Method

GetFilesInFolder (deprecated from v3.2)

ModuleFileSystem
LibraryCore
Action


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


Parameters

Directory (string): Full path of the directory whose contents will be returned.

Note

The Directory parameter name is only available from v3.2 onwards.

In v3.1 and earlier Folder must be used instead. While the earlier name will still work, we recommend that, from v3.2 onwards, Directory is used instead.

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

Return values

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

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

or

    • Folder '<folder>' is not a folder

If Directory 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 Directory itself can be opened and Recursive is true but then a subdirectory 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 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
These use the newer Directory parameter name. Replace with Folder for v3.1 and older.
Code Block
languageperl
 FileSystem.GetFilesInFolder(Directory:"c:\\tmp");


Code Block
languageperl
 FileSystem.GetFilesInFolder(Directory:"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 Directory itself then the instruction will return ExcutionError.

The method has been deprecated from v3.2. Please use GetFilesInDirectory instead.

...