Version

    ListFiles

    Short Description
    Ports
    Metadata
    ListFiles Attributes
    Details
    Examples
    Compatibility
    See also

    Short Description

    ListFiles lists directory contents including detailed information about individual files, e.g. size or modification date. Subdirectories may be listed recursively.

    ComponentInputsOutputsAuto-propagated metadata
    ListFiles0-11-2

    Ports

    Port typeNumberRequiredDescriptionMetadata
    Input0Input data records to be mapped to component attributes.Any
    Output0One record per each entry in the target directoryAny
    1ErrorsAny

    Metadata

    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.

    ListFiles Attributes

    AttributeReqDescriptionPossible values
    Basic
    File URLyes[1]

    The path to the file or directory to be listed (see Supported URL Formats for File Operations).

     
    Recursiveno 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 the standard output port. 
    Error mapping[2]Defines mapping of errors to the error output port. 
    Redirect error outputnoIf enabled, errors will be sent to the standard outputport instead of the error port.false (default) | true
    Advanced
    List directory contentsnoIf set to false, returns information about the directory, not its contents.true (default) | false
    Stop processing on failno

    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. Note: this function works only if an edge is connected to the component's error port.

    true (default) | false

    [1]  The attribute is required, unless specified in the Input mapping.

    [2]  Required if the corresponding edge is connected.

    Details

    Editing any of the Input, Output or Error mapping opens the Transform Editor.

    Input mapping

    The editor allows you to override selected attributes of the component with the values of the input fields.

    Field NameAttributeTypePossible values
    fileURLFile URLstring 
    recursiveRecursivebooleantrue | false
    Output mapping

    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 NameTypeDescription
    URLstringURL of the file or directory.
    namestringFile name.
    canReadbooleanTrue if the file can be read.
    canWritebooleanTrue if the file can be modified.
    canExecutebooleanTrue if the file can be executed.
    isDirectorybooleanTrue if the file exists and is a directory.
    isFilebooleanTrue if the file exists and is a regular file.
    isHiddenbooleanTrue if the file is hidden.
    lastModifieddateThe time that the file was last modified.
    sizelongTrue size of the file in bytes.
    resultboolean

    True if the operation has succeeded (can be false when Redirect error output is enabled).

    errorMessagestring

    If the operation has failed, the field contains the error message (used when Redirect error output is enabled).

    stackTracestring

    If the operation has failed, the field contains the stack trace of the error (used when Redirect error output is enabled).

    Error mapping

    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 NameTypeDescription
    resultbooleanWill always be set to false.
    errorMessagestringThe error message.
    stackTracestringThe stack trace of the error.

    Examples

    Listing Files
    Working with directories

    Listing Files

    List files in ${DATATMP_DIR} directory. Do not list content of subdirectories.

    Solution

    Use File URL and Input mapping attributes.

    AttributeValue
    File URL${DATATMP_DIR}
    Input mappingSee the code below.
    function integer transform() {
        $out.0.* = $in.1.*;
    
        return ALL;
    }

    You need an edge connected to the first output port.

    Working with directories

    We have the following directory tree structure:

    1. Check if the Clients directory exists.

    2. List the contents of the Clients directory.

    3. List the contents of any existing subdirectories in the Clients directory.

    Solution

    Use the File URL, Recursive and List directory contents attributes.

    AttributeValue
    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:

    Compatibility

    VersionCompatibility Notice
    4.6.0-M1The List directory contents attribute has been implemented.