Four Stars

How to get latest files from folder based on last run

How to get incremental files from same folder …in talend

I have to get files based on last job start date after which are files coming those files i need process..how i can achive this.pls help me..Thank you

1 ACCEPTED SOLUTION

Accepted Solutions
Twelve Stars TRF
Twelve Stars

Re: How to get latest files from folder based on last run

The simplest (the better?) is to move (using tfilecopy) the files to a special folder (archive for example) as soon they have been processed. Using this pattern, you don't have to worry about how many files you have processed last day. Just iterate over the filelist and that's all.

TRF
7 REPLIES
Twelve Stars TRF
Twelve Stars

Re: How to get latest files from folder based on last run

Store the last filename processed in a file (and reuse this information for next run) or rename the files after they have been processed.

TRF
Four Stars

Re: How to get latest files from folder based on last run

Hi TRF, Thanks for your response....My requirement is incremental files are coming to client server from that we need process the those files, which are newly coming from last run..

 

Ex: Yesterday 10 files came ---> we processed--

 

today 5 files came ---->total 15(yesterday 10+today 5)--from this i want to get latest files and need to process..

 

 

How we can this?

 

Please share the complete Talend Design ?

Thank you so much 

Six Stars

Re: How to get latest files from folder based on last run

Can you also send your file name format?? I am also facing same issue so,
I came up with a solution where i am getting all in tfilelist and iterate those file from tJava (compare those files and get next file , b4 that i will store last run job file name)
Can anyone give me better solution.. Thanks in Advance!!
Twelve Stars TRF
Twelve Stars

Re: How to get latest files from folder based on last run

The simplest (the better?) is to move (using tfilecopy) the files to a special folder (archive for example) as soon they have been processed. Using this pattern, you don't have to worry about how many files you have processed last day. Just iterate over the filelist and that's all.

TRF
Four Stars

Re: How to get latest files from folder based on last run

Hi Sir, Thank you for your response..but my client saying without achieve the files we need to process latest files based on last run 

Six Stars

Re: How to get latest files from folder based on last run

here is how to do that, we had same requirement on getting latest file from FTP,

 

basically we compare the files creation date & compare it with previous files creation date & that's how we basically sort the file & get latest file,

 

globalMap.get("sortedmtime") == null ? row1.mtime : (row1.mtime >= (long)globalMap.get("sortedmtime"))?row1.mtime:globalMap.get("sortedmtime")

image.png

 

There are so many other solution out there like using tbuffer to store all files & then use tSort to sort data

Four Stars

Re: How to get latest files from folder based on last run

Thanks Nmodi for your valuable solution..is it working for TOS?

 

I will try and update you.

 

Thanks