LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

FTP Delete multiple files

Solved!
Go to solution

I'm using the VI attached "programmatic FTP file transfer.vi" to move log files from a linux achine to my local machine using FTP. ( it works great)

After the transfer is complete i want to delete the files from my linux machine,

I'm using labview 2014.

 

I do not see a labview FTP delete multple vi

 

I already have the list of files and paths i want to delete in a array/cluster.

 

Any ideas ?

 

thanks,

James

0 Kudos
Message 1 of 5
(5,120 Views)

Looking at the FTP functions in LV2013, you are correct that there is no 'delete' function for a remote file deletion.

 

My suggestion would be to look through the VIs (for me at least, they are unlocked) and you should be able to create some new VIs which do the delete using the intermediate FTP functions. FTP is essentially a string based protocol so you just need to modify the part that sends the retrieve command to send the delete command instead.

 

Be careful that you don't overwrite the functions in the NI library though!


LabVIEW Champion, CLA, CLED, CTD
(blog)
0 Kudos
Message 2 of 5
(5,081 Views)

Open up the FTP Retrieve Multiple VI, and you'll see it's just a for loop wrapper around a low level FTP RETR command. You can do the exact same thing, but use FTP [DELE].vi located in vi.lib\FTP\ftp1.llb to delete multiple remote files.

 

I've attached a quick example, but it's untested!




Certified LabVIEW Architect
Unless otherwise stated, all code snippets and examples provided
by me are "as is", and are free to use and modify without attribution.
0 Kudos
Message 3 of 5
(5,072 Views)

Hello Michael,

 

Interserting your example code at the end of my code seems to work great!!

 

However my code now copys and deletes all the log files in the debian directory even the ones that are still being written to by my software program.

 

I assumed the unbundle by name "file" selection in my code would only copy accross files which have a file extension. ( but it copys all files)

Log files which are still being created by my software so not have a ".log" extension yet.

 

I want to filter my FTP file specification to only retrieve and delete files with a .log extension.

 

Any ideas ?

 

thanks,

James. 

 

 

0 Kudos
Message 4 of 5
(5,010 Views)
Solution
Accepted by topic author jamesy777

I think you've answered your own question, in that you need to filter the file listing for files which contain a .log extension. This can be done by using the string Match Pattern VI in the file selection loop.

 

If you specify a regular expression of log or more accurately \.log$ (which looks for .log at the end of a string), it will return an offset of the matched string. If there's no match it will return a -1. So you can check if the matched offset is greater than or equal to zero (ie. there is an .log extension), and then logically AND that with the check for file type.




Certified LabVIEW Architect
Unless otherwise stated, all code snippets and examples provided
by me are "as is", and are free to use and modify without attribution.
0 Kudos
Message 5 of 5
(4,995 Views)