Skip to main content Skip to complementary content
  • New archived content: Talend MDM, Talend Data Catalog 8.0, and Talend 7.3 products reached their end of life in 2024. Their documentation was moved to the Talend Archive page and will no longer receive content updates.
Close announcements banner

Deleting files

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

Job description.

Procedure

Procedure

  1. Place the following components from the Palette to the design workspace.
    • tFileList,
    • tFileDelete,
    • tJava.
  2. In the tFileList Basic settings view, set the directory to loop on in the Directory field.
    Basic settings view for tFileList.
    The filemask is "*.txt" and no case check is to carry out.
  3. 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.
    tFileDelete window for setting File Name.
  4. 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")).
  5. 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!" );
  6. Save your Job and press F6 to run it.
    Job results.

Results

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

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – please let us know!