tFileCopy - 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

tFileCopy Properties

Component family

File/Management

 

Function

This component copies a source file or folder into a target directory.

Purpose

This component helps to streamline processes by automating recurrent and tedious copy tasks.

Basic settings

File Name

Specify the path to the file to be copied.

This field does not appear when the Copy a directory check box is selected.

 

Copy a directory

Select this check box to copy a directory including all subdirectories and files in it.

 

Source directory

Specify the source directory to copy.

This field appears only when the Copy a directory check box is selected.

 

Destination directory

Specify the directory to copy the source file or directory to.

 

Rename

Select this check box if you want to rename the file copied to the destination.

This field does not appear when the Copy a directory check box is selected.

 

Destination filename

Specify a new name for the file to be copied.

This field appears only when the Rename check box is selected.

 

Remove source file

Select this check box to remove the source file after it is copied to the destination directory.

This field does not appear when the Copy a directory check box is selected.

 

Replace existing file

Select this check box to overwrite any existing file with the newly copied file.

This field does not appear when the Copy a directory check box is selected.

 

Create the directory if it doesn't exist

Select this check box to create the specified destination directory if it does not exist.

This field does not appear when the Copy a directory check box is selected.

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 a standalone component.

Global Variables

DESTINATION_FILENAME: the destination file name. This is an After variable and it returns a string.

DESTINATION_FILEPATH: the destination file path. This is an After variable and it returns a string.

SOURCE_DIRECTORY: the source directory. This is an After variable and it returns a string.

DESTINATION_DIRECTORY: the destination directory. This is an After 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

If you are using a subscription-based version of the Studio, 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: Restoring files from bin

This scenario describes a Job that iterates on a list of files in a directory, copies each file to a defined target directory, and then removes the copied files from the source directory.

  1. Create a new Job and add a tFileList component and a tFileCopy component by typing their names in the design workspace or dropping them from the Palette.

  2. Connect tFileList to tFileCopy using a Row > Iterate link.

  3. Double-click tFileList to open its Basic settings view.

  4. In the Directory field, browse to or type in the directory to iterated upon.

  5. Double-click tFileCopy to open its Basic settings view.

  6. In the File Name field, press Ctrl+Space to access the global variable list and select the tFileList_1.CURRENT_FILEPATH variable from the list to fill the field with ((String)globalMap.get("tFileList_1_CURRENT_FILEPATH")).

  7. In the Destination directory field, browse to or type in the directory to copy each file to.

  8. Select the Remove source file check box to get rid of the files that have been copied.

  9. Press Ctrl+S to save your Job and press F6 to execute it.

    All the files in the defined source directory are copied to the destination directory and are removed from the source directory.