Search code examples
fileftptalendfile-management

Get the latest/recent file from FTP to local using Talend


I have to create a job in Talend which will connect to One FTP. The FTP is having various files for each day with same prefix but different timestamp appended(yyyymmddhhmmss) in the filename. Example -

MyFile20151123142020.xml
MyFile20151123154748.xml

My requirement is to pick the latest or most recent file and copy to my local. I understand that this could be achieved either by referring to the latest timestamp in the filename or referring to the last modified time. I thought of proceeding with the later and my job looks like below - enter image description here

enter image description here

I dont know how to proceed further and how to use the latest mtime value to pick the most recent file.


Solution

  • After getting file properties, wen need to sort files by mtime or by basename then pick the first.

    • tSortRow : sort by mtime or basename if they have same pattern.

    • tSampleRow : "1" to get the first

    • tFTPGet : file mask = row3.basename (row3 the output flow of tSampleRow)

    enter image description here