Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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.
@Shicong Hong : Thank you!
This is what I ended up doing:
I 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
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
@Shicong Hong : Thank you!
This is what I ended up doing:
I 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
Great, thanks for your screenshot of job, it will helpful for others who have the same requirement.
Regards
Shong