tFileCopy
tFileCopy Standard properties
These properties are used to configure tFileCopy running in the Standard Job framework.
The Standard
tFileCopy component belongs to the File family.
The component in this framework is available in all Talend
products.
Basic settings
File Name |
Specify the path to the file to be copied. This field does not appear when the Copy a Warning: Use absolute path (instead of relative path) for
this field to avoid possible errors. |
Copy a directory |
Select this check box to copy a directory including all |
Source directory |
Specify the source directory to copy. This field appears only when the Copy a Warning: Use absolute path (instead of relative path) for
this field to avoid possible errors. |
Destination directory |
Specify the directory to copy the source file or directory Warning: Use absolute path (instead of relative path) for
this field to avoid possible errors. |
Rename |
Select this check box if you want to rename the file copied to the This field does not appear when the Copy a |
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 This field does not appear when the Copy a |
Replace existing file |
Select this check box to overwrite any existing file with the This field does not appear when the Copy a |
Create the directory if it doesn’t exist |
Select this check box to create the specified destination This field does not appear when the Copy a |
Advanced settings
tStatCatcher Statistics |
Select this check box to gather the Job processing metadata at a |
Global Variables
Global Variables |
DESTINATION_FILENAME: the destination file name. This is
DESTINATION_FILEPATH: the destination file path. This is
SOURCE_DIRECTORY: the source directory. This is an After
DESTINATION_DIRECTORY: the destination directory. This is
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 a 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 |
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.
![tFileCopy_1.png](https://resources.talendskill.com/document/talend-open-studio-for-esb/version-7x/org.talend.help_7.3.1.20200213_0931/components/tFileCopy_1.png)
Procedure
-
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. -
Connect tFileList to tFileCopy using a Row >
Iterate link. -
Double-click tFileList to open its Basic settings view.
-
In the Directory field, browse to or type in
the directory to iterated upon. -
Double-click tFileCopy to open its Basic settings view.
-
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”)). -
In the Destination directory field, browse to
or type in the directory to copy each file to. -
Select the Remove source file check box to
get rid of the files that have been copied. -
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.