LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Open most recently created text file in directory

I need be able to monitor a directory on my harddisk and open a new text file once it has been created.  I need to know if I can somehow sample the timestamps on new files as they come in and pull in a new file if its time stamp is newer than one I have on record.  Is there a way to search the files in a directory based on timestamps and not names?  Any ideas will be greatly appreciated.

Cheers
Message 1 of 6
(3,236 Views)
The File/Directory Info function found in the Files-Advanced palette will output a timestamp called Last Mod.  The List Folder function or Recursive File List function , also in the advanced palette, can give you a list of all the file names.  Use a loop to index all files in the list and use the File/Directory Info function to get timestamps for each file.
- tbob

Inventor of the WORM Global
Message 2 of 6
(3,227 Views)
Hmm. Not sure if this is still actual. For the record:

Use a List to get all the files in a directory. In a for loop use the File
Info to get the timestamp information.

Regards,

Wiebe.


Message 3 of 6
(3,101 Views)

Wiebe:

It depends on the version of LV.  The original question was posted in 2007.  I think I was using LV 7 when I posted my answer.

- tbob

Inventor of the WORM Global
Message 4 of 6
(3,075 Views)
The way I described it works in LV7 (, and probably even in LV4). How would
this be done differently in 8?

Anyway, every now and then I scan for unanswered questions. This question
didn't have an answer in my outlook, so I just replied...

Regards,

Wiebe.


Message 5 of 6
(3,051 Views)
Hi Wiebe,
 
The same method can work in LV 8.5.1.  You can use the Recursive File List.vi to get a list of all files in a folder, and then you can use the File/Directory Info.vi to display the timestamp from each file. 
 
Note that the Recursive File List.vi outputs an array of file path names, and the File/Directory Info.vi inputs only one file path name.  Since you want to read the timestamp from each file, just put the File/Directory Info.vi inside a For Loop so that each iteration of the loop allows it to access one index of the array.
 
Kevin Stuart
Applications Engineer
National Instruments
Message 6 of 6
(3,025 Views)