Skip to main content
Announcements
SYSTEM MAINTENANCE: Thurs., Sept. 19, 1 AM ET, Platform will be unavailable for approx. 60 minutes.
cancel
Showing results for 
Search instead for 
Did you mean: 
Haresh
Contributor
Contributor

How to get the last 2 days file from the remote ftp site?

I am trying to retrieve the last 2 days worth of files from the remote ftp site when they have 5000 odd files present in the sftp site.I just want to sort the file list by desc order and get the last 2 days files alone into the local folder.

i am thinking if there is any way to implement it without using tbufferoutput and iterating through all the list of the files(5000) in the ftp site.Is there a quicker way to do this ,please help.

Please see the job flow below:

i am trying to read the ftpfile properties like the date and sort by desc and give the range and fetch the latest 2 days only.

0693p000009s4jVAAQ.png

Urgently need a better solution

26 Replies
houssem_B
Contributor III
Contributor III

Sorry man

In the File mask you have to put only ((String)globalMap.get("FileName")) so delete ( +".*" ) it works for me don't forget to set your distant directory and your local directory

 

Let me know if there is any problem

 

0693p000009sJkEAAU.jpg

 

 

 

Haresh
Contributor
Contributor
Author

Thanks @houssem Boufaden​  it worked now and i was able to retrieve the files in the folder successfully,appreciate your help

houssem_B
Contributor III
Contributor III

Hello @Haresh Sivakumar​  please mark the comment 'as best' to help others

Haresh
Contributor
Contributor
Author

@houssem Boufaden​ so i just analyzed closer and figured that that tmap function i am using especially in the expression editor to filter out the files from the last 1 or 2 days,in this case just a day before based on mtime_string for the prior day but it is infact pulling in all the files beyond the 1 day (it is fetching last 3 days files -when i want just 1 day before files) TalendDate.diffDate(TalendDate.getCurrentDate(),TalendDate.parseDate("EEE MMM dd HH:mm:ss zzz yyyy",row8.mtime_string),"dd") <=1

 

What is incorrect here?

 

houssem_B
Contributor III
Contributor III

@Haresh Sivakumar​  try this one

TalendDate.diffDate(TalendDate.parseDate("yyyy-MM-dd",TalendDate.getDate("yyyy-MM-dd")),TalendDate.parseDate("EEE MMM dd HH:mm:ss zzz yyyy",row8.mtime_string)) <2

 

make sure that your pattern is correct

 

 

 

Haresh
Contributor
Contributor
Author

Awesome,worked now like a charm 🙂

houssem_B
Contributor III
Contributor III

Perfect !! 😄

good luck for you