Short Description |
Ports |
Metadata |
ListFiles Attributes |
Details |
Examples |
Compatibility |
See also |
ListFiles lists directory contents including detailed information about individual files, e.g. size or modification date. Subdirectories may be listed recursively.
Note | |
---|---|
To be able to use this component, you need a separate jobflow license. |
Component | Inputs | Outputs | Auto-propagated metadata |
---|---|---|---|
ListFiles | 0-1 | 1-2 |
Port type | Number | Required | Description | Metadata |
---|---|---|---|---|
Input | 0 | Input data records to be mapped to component attributes. | Any | |
Output | 0 | One record per each entry in the target directory | Any | |
1 | Errors | Any |
ListFiles does not propagate metadata from left to right or from right to left.
The component has metadata templates available. See Details or general info on Metadata Templates.
Attribute | Req | Description | Possible values |
---|---|---|---|
Basic | |||
File URL | yes [1] | Path to the file or directory to be listed (see Supported URL Formats for File Operations). | |
Recursive | no | List subdirectories recursively. (Has no effect if List directory contents is set to false .)
| false (default) | true |
Input mapping | [2] | Defines mapping of input records to component attributes. | |
Output mapping | [2] | Defines mapping of results to standard output port. | |
Error mapping | [2] | Defines mapping of errors to error output port. | |
Redirect error output | no | If enabled, errors will be sent to the standard output port instead of the error port. | false (default) | true |
Advanced | |||
List directory contents | no | If set to false , returns information about the directory, not its contents. | true (default) | false |
Stop processing on fail | no | By default, a failure causes the component to skip all subsequent input records and send the information about skipped input records to the error output port. This behavior can be turned off by this attribute. | true (default) | false |
[1] The attribute is required, unless specified in the Input mapping. [2] Required if the corresponding edge is connected. |
Editing any of the Input, Output or Error mapping opens the Transform Editor.
The editor allows you to override selected attributes of the component with the values of the input fields.
Field Name | Attribute | Type | Possible values |
---|---|---|---|
fileURL | File URL | string | |
recursive | Recursive | boolean | true | false |
The editor allows you to map the results and the input data to the output port.
If output mapping is empty, fields of input record and result record are mapped to output by name.
Field Name | Type | Description |
---|---|---|
URL | string | URL of the file or directory. |
name | string | File name. |
canRead | boolean | True if the file can be read. |
canWrite | boolean | True if the file can be modified. |
canExecute | boolean | True if the file can be executed. |
isDirectory | boolean | True if the file exists and is a directory. |
isFile | boolean | True if the file exists and is a regular file. |
isHidden | boolean | True if the file is hidden. |
lastModified | date | The time that the file was last modified. |
size | long | True size of the file in bytes. |
result | boolean | True if the operation has succeeded (can be false when Redirect error output is enabled). |
errorMessage | string | If the operation has failed, the field contains the error message (used when Redirect error output is enabled). |
stackTrace | string | If the operation has failed, the field contains the stack trace of the error (used when Redirect error output is enabled). |
The editor allows you to map the errors and the input data to the error port.
If error mapping is empty, fields of input record and result record are mapped to output by name.
Field Name | Type | Description |
---|---|---|
result | boolean | Will always be set to false. |
errorMessage | string | The error message. |
stackTrace | string | The stack trace of the error. |
Listing Files |
Working with directories |
List files in ${DATATMP_DIR}
directory.
Do not list content of subdirectories.
Use File URL and Input mapping attributes.
Attribute | Value |
---|---|
File URL | ${DATATMP_DIR} |
Input mapping | See the code below. |
function integer transform() { $out.0.* = $in.1.*; return ALL; }
You need an edge connected to the first output port.
We have the following directory tree structure:
Check if the Clients
directory exists.
List the contents of the Clients
directory.
List the contents of any existing subdirectories in the Clients
directory.
Use the File URL, Recursive and List directory contents attributes.
Attribute | Value |
---|---|
File URL | ${DATAIN_DIR}/Clients/ |
List directory contents | false |
Recursive | false (default) |
Enable debugging on edges and run the graph. The graph has confirmed the directory exists:
Next, set the List directory contents to true
(default)
and run the graph again. The graph has now listed the contents of the Clients
directory:
Now, set the Recursive attribute to true
and run the graph.
The graph has now listed the contents of the Clients
directory and all subdirectories:
The List directory contents attribute has been implemented.