LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Parse files in directory newer than MM/DD/YYYY

Solved!
Go to solution

In the attached VI I am trying to figure out how to pull in and parse all .txt log files in Folder path newer than a particular date instead of just the *.txt (all text files) as it is set to now. The date I will be entering from a sub VI is a string in the format MM/DD/YYYY. The date & time are included in the file names. The comma delimited .txt file names are broken down into "TesterID UUTSerial# Date TimeTested.txt". I have attached one of the comma delimited .txt files that the path contains. Anyone have any suggestions? I am running LV2009 SP1.

 

Thanks!

Download All
0 Kudos
Message 1 of 4
(2,855 Views)

Feed your filenames array output from List File to a loop with indexing enabled.  Then for each filename, you have to parse out the date.  If it always starts at the same character position, you can use String Subset to get it out.  Or you could use Match Pattern, look for the fist letter character as a starting point.  Once you get the date, then you must compareit to the MM/DD/YYYY string.  This is the tricky part.  You need to compare the year first, then the month, then the date.  Send a boolean of the compare result to a case structure.  You will need to use a shift register initialized by an empty string array.  Inside the True case, use build array to add the filename to the output list (shift register contents).  In the False case, just wire the shfit register wire straight though.  The output will be a list of files you desire.

 

17827i80B2E61A13F945D5

- tbob

Inventor of the WORM Global
0 Kudos
Message 2 of 4
(2,848 Views)
Solution
Accepted by topic author aaronb

Extracting the date from the filename and comparing it to an input date seemed like a fun thing to write.  So I wrote a VI to do that.  Here it is.  Just wire in the filenames array and the desired date to compare.  The output is a list of files that are greater than or equal to the specified date.  You can change the compare function if you want something different.  The filename must have a 3-letter month followed by a space, followed by a date, another space, the year, a space then whatever else.  The compare date must be in the form mm/dd/yyyy.

 

- tbob

Inventor of the WORM Global
Message 3 of 4
(2,838 Views)

This worked perfectly for my application.....Thanks tbob!

0 Kudos
Message 4 of 4
(2,801 Views)