Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
smaria
Contributor
Contributor

Talend Job Copy files based on certain conditions

Hello,

I am really new to Talend. I am developing a job to copy files from source directory to destination directory based on certain conditions. I am using tFileExist component to find if the source file name exists in the destination directory.

If it does not, I am copying the file. If the file name does exist in the destination directory, I want to compare the file size and file date. If any of these two parameters differ, then I want to copy the source file and change the destination file name to "filename_original".

So far I am using tFileList -> TFileExist (if filename does not exist)-> tFileCopy.

I am not able to figure out how to proceed further, that is getting the file size and file date and making the comparison.

Please help. Thanks.

Labels (2)
1 Solution

Accepted Solutions
smaria
Contributor
Contributor
Author

@Shicong Hong​ : Thank you!

This is what I ended up doing:

0695b00000Uyg7dAAB.pngI got the file size and file date of the destination file at tJavaRow_2 and then compared it with the file size and file date of the source file which I got at tJavaRow_1.

 

Thanks,

smaria

 

View solution in original post

3 Replies
Anonymous
Not applicable

Hi

Using tFileProperties to read the file properties including sizes, modified date etc, compare the two properties sizes and modified date on a tJavaRow, set the result to a global variable (boolean type), this variable will be used as the condition of runIf connector that trigger tFileCopy component, the job looks like:

tFileList -> iterate--TFileExist (if filename does not exist)->runIf1-->tFileCopy1

********************************************(if file already exists)->runIf2--tFileProperties--main--tJavaRow--runIf--tFIleCopy2

 

Please try and let me know if you still have any quesitons.

 

Regards

Shong

smaria
Contributor
Contributor
Author

@Shicong Hong​ : Thank you!

This is what I ended up doing:

0695b00000Uyg7dAAB.pngI got the file size and file date of the destination file at tJavaRow_2 and then compared it with the file size and file date of the source file which I got at tJavaRow_1.

 

Thanks,

smaria

 

Anonymous
Not applicable

Great, thanks for your screenshot of job, it will helpful for others who have the same requirement.

 

Regards

Shong