LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

list files sequentially: 0,1,2...,10,11...,99,100, etc.. without timestamp

Solved!
Go to solution

Hi there,

 

I keep running into a problem whenever I need to list files sequentially. Instead of 0,1,2,...10,11,12...100,101,... The files get listed in the following "alphabetical" order: 0,1,10,100,101,...11,110,...,12,120,121,...,2,20,200...

 

I understand that a simple solution would be to list the files by timestamp, and I have done this in the past, but this solution is not available to me this time.

The timestamp on files is very sensitive: Sometimes I need to manually mess with some of the files after I create them, thus reseting the timestamp on them. Another problem comes up when I create files too quickly, they end up sharing the same timestamp again being sorted incorrectly/alphabetically. A solution to that is to create files with an artificial time delay of a second between creations. This is very time consuming and not feasible in real-time applications.

 

Sorry to get longwinded. I'm just wondering if there is a simple way to list files from a folder sequentially by just using their filename (which ends on a #)?

0 Kudos
Message 1 of 7
(4,186 Views)

This issue is because Windows sorts file names alphabetically, 1 comes before 10, before 11, which are before 2, 20, 21.

 

You should create the file names zero filled.  If you know that you will go up to 99 files, name them 01, 02, ... 09, 10, 11 , 99.  If you need more than 100, go 001, 002, ... 010, .  099, 100, 101 ... 999.  Then the alphbetical sorting will also be numerically sorted.

Message 2 of 7
(4,185 Views)

Hi

In windows both the date/time for creating and last mod are saved in the file. 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. So take a look at my solution in this post http://forums.ni.com/ni/board/message?board.id=170&message.id=384761#M384761. It may be what you want to do



Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
(Sorry no Labview "brag list" so far)
0 Kudos
Message 3 of 7
(4,160 Views)

The first For Loop is only there to make some data for me to work with; you'd replace that with your array of file names.  Replace the Decimal String To Number function I used with a Match Pattern (to get the number from your file's name) and you'll have a cluster of integer & string which will sort the way you want it to.

 

Message Edited by jcarmody on 03-03-2009 05:39 AM
Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

Download All
Message 4 of 7
(4,151 Views)
PS - the inspiration for my previous post came from one of Darren's recent nuggets.
Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

Message 5 of 7
(4,142 Views)

jcarmody,

 

Very nice application of Darren's nugget.   

0 Kudos
Message 6 of 7
(4,119 Views)
Solution
Accepted by topic author yegeniy
Thank you jcarmody. That was much easier than I thought it'd be. I attached the solution
0 Kudos
Message 7 of 7
(4,086 Views)