August 17, 2023

tFileDelete – Docs for ESB 5.x

tFileDelete

tFileDelete.png

tFileDelete Properties

Component family

File/Management

 

Function

Suppresses a file from a defined directory.

Purpose

Helps to streamline processes by automating recurrent and tedious
tasks such as delete.

Basic settings

File Name

Path to the file to be deleted. This field is hidden when you select the Delete folder check box or the Delete file or folder check box.

 

Directory

Path to the folder to be deleted. This field is available only
when you select the Delete folder
check box.

 

File or directory to delete

Enter the path to the file or to the folder you want to delete.
This field is available only when you select the Delete file or folder check box.

 

Fail on error

Select this check box to prevent the main Job from being executed if an error occurs,
for example, if the file to be deleted does not exist.

 

Delete Folder

Select this check box to display the Directory field,
where you can indicate the path the folder to be deleted.

 

Delete file or folder

Select this check box to display the File or directory to
delete
field, where you can indicate the path to the
file or to the folder you want to delete.

Advanced settings

tStatCatcher Statistics

Select this check box to gather the Job processing metadata at a
Job level as well as at each component level.

Usage

This component can be used as standalone component.

Global Variables

DELETE_PATH: the path to the deleted file or folder. This
is an After variable and it returns a string.

CURRENT_STATUS: the execution result of the component.
This is a Flow variable and it returns a string.

ERROR_MESSAGE: the error message generated by the
component when an error occurs. This is an After variable and it returns a string. This
variable functions only if the Die on error check box is
cleared, if the component has this check box.

A Flow variable functions during the execution of a component while an After variable
functions after the execution of the component.

To fill up a field or expression with a variable, press Ctrl +
Space
to access the variable list and choose the variable to use from it.

For further information about variables, see Talend Studio
User Guide.

Connections

Outgoing links (from this component to another):

Row: Main.

Trigger: On Subjob Ok; On Subjob
Error; Run if; On Component Ok; On Component Error.

Incoming links (from one component to this one):

Row: Main; Reject; Iterate.

Trigger: Run if; On Subjob Ok; On
Subjob Error; On component Ok; On Component Error; Synchronize;
Parallelize.

For further information regarding connections, see
Talend Studio User
Guide
.

Log4j

The activity of this component can be logged using the log4j feature. For more information on this feature, see Talend Studio User
Guide
.

For more information on the log4j logging levels, see the Apache documentation at http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/Level.html.

Limitation

n/a

Scenario: Deleting files

This very simple scenario describes a Job deleting files from a given
directory.

Use_Case_tFileDelete1.png
  1. Drop the following components: tFileList,
    tFileDelete, tJava from the Palette to the
    design workspace.

  2. In the tFileList
    Basic settings, set the directory to loop on in
    the Directory field.

    Use_Case_tFileDelete2.png
  3. The filemask is “*.txt” and no case check is to carry
    out.

  4. In the tFileDelete
    Basic settings panel, set the File Name field in order for the current file in
    selection in the tFileList component be
    deleted. This delete all files contained in the directory, as specified
    earlier.

    Use_Case_tFileDelete3.png
  5. press Ctrl+Space bar to access the list of
    global variables. In Java, the relevant variable to collect the current file is:
    ((String)globalMap.get(“tFileList_1_CURRENT_FILEPATH”)).

  6. Then in the tJava component, define the
    message to be displayed in the standard output (Run console). In this Java use
    case, type in the Code field, the following script: System.out.println(
    ((String)globalMap.get(“tFileList_1_CURRENT_FILE”))

    + ” has been deleted!” );

  7. Then save your Job and press F6 to run
    it.

    Use_Case_tFileDelete4.png

The message set in the tJava component displays in
the log, for each file that has been deleted through the tFileDelete component.


Document get from Talend https://help.talend.com
Thank you for watching.
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x