Version

    DeleteFiles

    Jobflow Component

    Short Description
    Ports
    Metadata
    DeleteFiles Attributes
    Details
    Examples
    See also

    Short Description

    DeleteFiles can be used to delete files and directories (also recursively).

    [Note]Note

    To be able to use this component, you need a separate jobflow license.

    ComponentInputsOutputsAuto-propagated metadata
    DeleteFiles0-10-2

    Ports

    Port typeNumberRequiredDescriptionMetadata
    Input0Input data records to be mapped to component attributes.Any
    Output0ResultsAny
    1ErrorsAny

    Metadata

    DeleteFiles does not propagate metadata from left to right or from right to left.

    This component has metadata templates. For details on DeleteFiles metadata templates, see Details or metadata templates for general info on metadata templates.

    DeleteFiles Attributes

    AttributeReqDescriptionPossible values
    Basic
    File URLyes[1]

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

     
    RecursivenoDelete directories recursively.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 outputnoIf enabled, errors will be sent to the standard output port instead of the error port.false (default) | true
    Verbose outputno

    If enabled, one input record may cause multiple records to be sent to the output (e.g. as a result of wildcard expansion). Otherwise, each input record will yield just one cumulative output record.

    false (default) | true
    Advanced
    Stop processing on failno

    By default, a failure causes the component to skip all subsequent input records and send the information about skipped input files to the error output port. This behavior can be turned off by this attribute.

    False: If an error occurs (e.g. file cannot be found), the component will continue deleting subsequent files.

    True: If an error occurs, the component will stop deleting subsequent files and will send the information about skipped operations to the error port. 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
    fileURLstringThe path to the file or directory that was deleted.
    resultbooleanTrue if the operation has succeeded (can be false when Redirect error output is enabled).
    errorMessagestringIf the operation has failed, the field contains the error message (used when Redirect error output is enabled).
    stackTracestringIf 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.
    fileURLstringURL of the deleted file or directory.

    Examples

    Deleting a Single File
    Deleting Directories
    Stop Deleting if Deleting Fails

    Deleting a Single File

    Delete a file ${DATATMP_DIR}/delete_me.txt.

    Solution

    Use File URL attribute.

    AttributeValue
    File URL${DATATMP_DIR}/delete_me.txt

    Deleting Directories

    Delete directory ${DATATMP_DIR}/old_directory with all files.

    Solution

    Use File URL and Recursive.

    AttributeValue
    File URL${DATATMP_DIR}/old_directory
    Recursivetrue

    Note: you need to check the recursive attribute also in the case of deleting a single empty directory.

    Stop Deleting if Deleting Fails

    Delete files from the following list. If any of the files cannot be deleted, stop and don't delete the following items from the list.

    file1.txt
    file2.txt
    file3.txt

    The files file1.txt and file3.txt exist, the file file2.txt does not exist.

    Solution

    Get file URLs from the input port one by one and set Stop processing on fail to true (default value).

    This does not cause jobflow to fail!