fileListDir

Version 24.2.9039


fileListDir


Lists the files and directories in the specified path.

Required Parameters

  • path: The fully qualified path whose directories and files will be listed (for example, /tmp/mydirectory).

Optional Parameters

  • mask: The pattern to use for filtering the result entries. The default is *. For example, a mask of *.json matches all files with a .json extension.
  • recurse: Whether to list entries recursively. The allowed values are false and true. The default is false.
  • fileordir: Whether to list only files or directories. The allowed values are all, files, and dirs. The default is all.

Output Attributes

  • file:fullname: The full path of the file or directory in the current entry.
  • file:name: The name of the file or directory in the current entry.
  • file:mtime: The time at which the file or directory in the current entry was written to.
  • file:ctime: The time at which the file or directory in the current entry was created.
  • file:atime: The time at which the file or directory in the current entry was last read from or written to.
  • file:attributes: A list of attributes of the file or directory in the current entry.
  • file:extension: The extension of the file in the current entry.
  • file:size: The size of the file in bytes.
  • file:isdir: Whether the entry is a file or directory.

Example

<!-- Setting the path to monitor on the input item -->
<arc:set attr="input.path" value="/tmp/timesensitive" />
<!-- Enabling recursion to check all subdirectories within the input path -->
<arc:set attr="input.recurse" value="true" />
<!-- Checking for files only, across all directories found by the operation -->
<arc:set attr="input.fileordir" value="files" />
<!-- Calling the operation and passing in the input item and setting an output item -->
<arc:call op="fileListDir" in="input" out="result" >
  <!-- Executing an expression that checks each file creation date in each directory -->
  <arc:if exp="[result.file:ctime | dateadd('day', 1) | datediff | lessthan(0)]" >
    <!-- If it is older than 1 day, log an entry in the application log -->
    <!-- This can be expanded to add more logic such as sending an email using appSendEmail -->
    <arc:set attr="_log.info" value="The file [result.file:name] located at [result.file:fullname] has been idle within [input.path] for longer than 1 day." />
  </arc:if>
</arc:call>