LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to get Latest file from a Folder

Hi,

      I would like to access latest file in a folder based upon time stamp in the file properties. Can anybody help me in this regard.

 

Regards,

Visuman 

0 Kudos
Message 1 of 6
(4,229 Views)

Hi visuman,

 

use ListFolder to get all filenames. Then use "File/Dir-Info" to get the "Last Changed" timestamp for each file. Sort by timestamp to find the latest file...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 6
(4,214 Views)

Hey,

 

I hope this solves your problem.

 

If you have any questions, just ask them 🙂

 

Greetz, Bart

 

P.S. the solution is in the attachment 🙂

 

0 Kudos
Message 3 of 6
(4,211 Views)

Hi Bart,

 

- you don't need ArraySize in your snippet, autoindexing will do the job.

- using the clean up button before posting might be a good idea too. 😄

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 6
(4,205 Views)
Cleanup button was used, and you're right about the ArraySize, just common practice from other programming languages 🙂
0 Kudos
Message 5 of 6
(4,200 Views)

@Bart_Aerts wrote:
Cleanup button was used,

I could well believe it. Clean up can commonly un-clean a diagram! Smiley Very Happy

 

note that your output "element" will just be the latest filename, not the filepath. As you don't provide the path as an input, but generate it internally from a dialog, the path is therefore lost when calling this code as a subVI, so you should also provide the root path as an output. And rename 'element' to 'filename' and 'max value' to 'timestamp' perhaps.

Thoric (CLA, CLED, CTD and LabVIEW Champion)


0 Kudos
Message 6 of 6
(4,156 Views)