Get newest file from FTP server

Discuss RoboTask here
Post Reply
Rukbunker
Posts: 192
Joined: Mon Feb 22, 2016 4:06 pm
Location: Netherlands

Get newest file from FTP server

Post by Rukbunker »

Hey Oleg,

I'm struggling a bit how to proceed with this: on a weekly schedule we want to download 1 file from an FTP server. That's working great so far, but sometimes the filename changes, so I cannot use a fixed filename / format / variables like ddmmyyyy. :?

To overcome this I've used the "FTP File loop". But in theory, it can result in 3 files and I only want to the download the most recent one, so I just want to have 1 result. So the loop should stop after finding the first file, because I've sorted it on File Time and descending order and spits the list to a variable.

What is the best approach in this, what can you advise? Keep the loop, and use just the 1st line out of my exported variable? (TXT Extract line)
Oleg
Site Admin
Posts: 3004
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: Get newest file from FTP server

Post by Oleg »

What is the best approach in this, what can you advise? Keep the loop, and use just the 1st line out of my exported variable? (TXT Extract line)
Yes, this is the best way. Use a file loop, sort by file time in descending order, and break the loop after the 1st element.
I would do the same.
Oleg Yershov
Post Reply