tFileDelete
tFileDelete Standard properties
These properties are used to configure tFileDelete running in the Standard Job framework.
The Standard
tFileDelete component belongs to the File family.
The component in this framework is available in all Talend
products.
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. Warning: Use absolute path (instead of relative path) for
this field to avoid possible errors. |
Directory |
Path to the folder to be deleted. This field is available only Warning: Use absolute path (instead of relative path) for
this field to avoid possible errors. |
File or directory to delete |
Enter the path to the file or to the folder you want to delete. Warning: Use absolute path (instead of relative path) for
this field to avoid possible errors. |
Fail on error |
Select this check box to prevent the main Job from being executed if an error occurs, |
Delete Folder |
Select this check box to display the Directory field, |
Delete file or folder |
Select this check box to display the File or directory to |
Advanced settings
tStatCatcher Statistics |
Select this check box to gather the Job processing metadata at a |
Global Variables
Global Variables |
DELETE_PATH: the path to the deleted file or folder. This
CURRENT_STATUS: the execution result of the component.
ERROR_MESSAGE: the error message generated by the A Flow variable functions during the execution of a component while an After variable To fill up a field or expression with a variable, press Ctrl + For further information about variables, see |
Usage
Usage rule |
This component can be used as standalone component. |
Connections |
Outgoing links (from this component to another): Row: Main.
Trigger: On Subjob Ok; On Subjob Incoming links (from one component to this one): Row: Main; Reject; Iterate.
Trigger: Run if; On Subjob Ok; On For further information regarding connections, see |
Deleting files
This very simple scenario describes a Job deleting files from a given
directory.
Procedure
-
Drop the following components: tFileList,
tFileDelete, tJava from the Palette to the
design workspace. -
In the tFileList
Basic settings, set the directory to loop on in
the Directory field. -
The filemask is “*.txt” and no case check is to carry
out. -
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. -
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”)). -
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!” ); -
Then save your Job and press F6 to run
it.
The message set in the tJava component displays in
the log, for each file that has been deleted through the tFileDelete component.