LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Find newest file in directory and delete after 10 files

Solved!
Go to solution

Hello,

i want to create a vi that can do two things

1. Input: 1. Directory 2. Number

2. Output: newest file in the specified directory

3. Delete all old files if number is two big, so if number = 2 then only keep two newest files in the directory and delete the rest

 

How can i do this? I cant find andy function to get the date of a file?

 

Thanks for your help

0 Kudos
Message 1 of 6
(5,273 Views)

By "date of file" do you mean the date it was created or the date is was modified?

 

- Matt

0 Kudos
Message 2 of 6
(5,268 Views)
The File/Directory Info function returns the last date modified, if that's what you're looking for.
0 Kudos
Message 3 of 6
(5,248 Views)

Hi OnlyOne,

see this link for an example.

 

Mike

0 Kudos
Message 4 of 6
(5,232 Views)
Solution
Accepted by topic author OnlyOne

Hi

Labview has a function called "File/Directory Info" this will give you the date for last modification. This may not be the same as date created. This function is used in a cool example called "\Listbox for File Explorer Demo.vi" find it with example finder. But as I said the modification data and creation date may not be the same. So I made something using the dir command and system exe function. Much better I think. The dir command is documented here http://www.computerhope.com/dirhlp.htm. The result is in the VI  enclosed. You may have to modify it, to fit you need

 



Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
(Sorry no Labview "brag list" so far)
Message 5 of 6
(5,216 Views)

Hi t06afre,

thanks for the great example. Works perfect.

0 Kudos
Message 6 of 6
(5,176 Views)