Scenario: Deleting files - 6.1

Talend Components Reference Guide

EnrichVersion
6.1
EnrichProdName
Talend Big Data
Talend Big Data Platform
Talend Data Fabric
Talend Data Integration
Talend Data Management Platform
Talend Data Services Platform
Talend ESB
Talend MDM Platform
Talend Open Studio for Big Data
Talend Open Studio for Data Integration
Talend Open Studio for Data Quality
Talend Open Studio for ESB
Talend Open Studio for MDM
Talend Real-Time Big Data Platform
task
Data Governance
Data Quality and Preparation
Design and Development
EnrichPlatform
Talend Studio

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

  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.

  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.

  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.

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