Home > Community > Discussion Forums


Showing results for 
Search instead for 
Do you mean 
Posts: 7

list all files in a directory in order of timestamp

have files from directory displayed in an array of columns,using the list icon. however i would like them to be in order of aquisition or timestamp, rather then all 1, 10ns 20s etc.
is there anyway to control the indexing with time stamping order?
Active Participant
Posts: 340

Re: list all files in a directory in order of timestamp

LabVIEW allows you to sort just about anything. All you have to do is create a cluster containing everything you want for a "record" and make an array of those clusters. In your case, you want to cluster the file name with its time stamp (how about last modification date?). The sort function (we call them functions or VIs, not icons) will order your array based on the order in which you clustered your elements.

I whipped up a tiny example. Give it a directory path and run it. The output is a list of the filed in that folder sorted according to their time stamp.

If you have some clear specifications for your whole application, consider hiring an Alliance Member (like us). You will end up with a most professional example of LabVIEW code t
o learn from and tweak as you like.

Alliance Members are here to help. We do this stuff every day.

Daniel L. Press
PrimeTest Corp.
Trusted Enthusiast
Posts: 2,556

Re: list all files in a directory in order of timestamp

Loop over each file
--- Use the FILE/DIRECTORY INFO function to get the MOD DATE of each file.
--- Bundle the MOD DATE with the path, or whatever else you need about the file.
--- Make sure the MOD DATE is FIRST in the cluster.
--- Use auto-indexing to make an array of these clusters.

When the loop is done, run the array of clusters through the SORT 1-D ARRAY function.

Now they are sorted in increasing order (oldest first).
Reverse that array if you need youngest first.

DO what you need to with the sorted array.
Steve Bird
Culverson Software - Elegant software that is a pleasure to use.

Blog for (mostly LabVIEW) programmers: Tips And Tricks

Posts: 7

Re: list all files in a directory in order of timestamp

ty for your help, this was exactly what I needed