LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Copy FTP files according to modified date and time

Solved!
Go to solution

Hi all,

I am creating an application where I need to copy the latest file created only from a remote FTP location. So for example, if my remote/ftp location contain some folders and some files, it would list only the file which was modified recently.

Right now, both NLST and LIST commands are giving me full list of folder and files directly, but I need only the file which was recently modified.

 

Can anyone help me out?

-FraggerFox!
Certified LabVIEW Architect, Certified TestStand Developer
"What you think today is what you live tomorrow"
0 Kudos
Message 1 of 6
(14,258 Views)
Solution
Accepted by topic author FraggerFox

Hi

 

Unfortunately the LIST command(s) don't return proper usable modification dates/times.

But there's a special FTP command 'MDTM' to get the modification date of a specified file.

You'll have to execute this command for each file individually.

 

Are you using the FTP functions from the Internet toolkit? Then you can do it like this:

 

FTP-ModDate.PNG

 

In the reply string you'll get the reply code (250 for successful operation) and the modification date.

 

I think you'll have to find the latest file with some code on the host system based on these modification dates.

 

Hope this helps

 

Message Edited by dan_u on 03-17-2010 02:59 PM
Message 2 of 6
(14,248 Views)

Thanks, this works.

Is there any other command which would let me copy only the latest modified file?

-FraggerFox!
Certified LabVIEW Architect, Certified TestStand Developer
"What you think today is what you live tomorrow"
0 Kudos
Message 3 of 6
(14,239 Views)

I don't believe so.

 

Look in vi.lib\addons\internet\ftp\ftp1.llb for the tested and supported LabVIEW FTP raw client functions.

 

For a list of the defined FTP commands, see this document. Note that the server you are talking to may or may not support the full list.

0 Kudos
Message 4 of 6
(14,233 Views)

Ok,

I believe creating a VI for parsing the reply string and comparing files on Time stamp returned by above function is too tedious task

-FraggerFox!
Certified LabVIEW Architect, Certified TestStand Developer
"What you think today is what you live tomorrow"
0 Kudos
Message 5 of 6
(14,230 Views)

What about the file names, do you have access to the code that creates the files? If the file names would start with something like YYYYMMDD-hhmmss (wouldn't that be nice?) you can just retrieve the file list and sort it, then get the latest file.

 

I don't think an FTP server supports anything that helps you with that, I think you have to get the file list and work with it on the host.

 

Message Edited by dan_u on 03-17-2010 04:12 PM
Message 6 of 6
(14,227 Views)