Moving, copying, renaming, and deleting files and folders
As well as reading from and writing to files, Talend has a set of components that allow developers to perform file functions without the need to call native operating system commands. This recipe shows the basic file management components.
Getting ready
Open the job jo_cook_ch08_0100_basicFileCommands
.
How to do it...
In the following recipes, it is worth noting that Talend uses the Linux style forward slash (/) in the file paths, as opposed to the Windows backslash (\).
Copying a file to another directory
Drag
tFileCopy
to the job.Set the file name to be
context.cookbookData+"/chapter8/chapter08_jo_0100_copyFile.txt"
.Set the output directory to be
context.cookbookData+"/outputData/chapter8"
.Run the job, and you will see that the new file has been created: This is a simple copy.
Copying file to a different name
Open
tFileCopy
, tick the Rename box, and then add a Destination filename ofchapter08_jo_0100_copyFileRenamed.txt
.Run the job, and...