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.

Component Inputs Outputs Auto-propagated metadata
DeleteFiles0-10-2
yes

Icon

Ports

Port typeNumberRequiredDescriptionMetadata
Input0
no
Input data records to be mapped to component attributes.Any
Output0
no
ResultsAny
1
no
ErrorsAny

Metadata

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

This component has metadata templates. See Details for details on DeleteFiles metadata templates or see Metadata Templates for general info on metadata templates.

DeleteFiles Attributes

AttributeReqDescriptionPossible values
Basic
File URLyes [1] 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 outputnoIf 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 behaviour can be turned off by this attribute.

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

True: If error occurs, the component will stop deleting of subsequent files and will send the information about skipped operations to the 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
fileURLstringPath 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 recursive attribute also in case of deleting of a single empty directory.

Stop Deleting if Deleting Fails

:

Delete files from the following list. If any of files cannot be deleted, stop do no delete following items of 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!

See also

CreateFiles
MoveFiles
Common Properties of Components
Specific Attribute Types
Common Properties of File Operations
File Operations Comparison