01-09-2003 02:32 PM
01-10-2003 07:44 AM
01-10-2003 01:22 PM
01-10-2003 03:04 PM
09-13-2005 02:26 AM - edited 09-13-2005 02:26 AM
Message Edited by Mads on 09-13-2005 02:30 AM
09-13-2005 03:38 AM
09-13-2005 04:09 AM
04-20-2020 07:02 PM - edited 04-20-2020 07:03 PM
Very good Ben "Knight of NI"!
You described it perfectly!
Thanks a lot!
04-21-2020 02:22 AM
@praveen193380 wrote:
Very good Ben "Knight of NI"!
You described it perfectly!
Thanks a lot!
So, give him a kudo!
04-21-2020 08:20 AM
@cjs a écrit :
That is perfect. Thank you.
I do have one more problem though, and I'm sure it is a simple thing, I just don't really know what I am doing. I can't quite seem to figure out a simple way of pulling the numeric part out. Well, I can do it if I know exactly what the "base" part of the file names is, ie. base 1.txt, base 2.txt, base 3.txt...
But I was hoping you could tell me how to get the numeric off the end if "base" was of an unknown length and could possibly contain numbers itself. The only guarantee on the file name is that it will end with a space, a number, period, and the extension.
I can use the Number To Decimal String function to read off the numeric and convert it to a number but this requires that I know exactly where the number starts and
I would like to be able to do this without knowing what the "base" part of the file name is (or how long) is. I tried reversing the order of the string thinking that then I know that the numeric I want begins in position 4. But then if it ends in any zeros, they become leading zeros when I reverse it and the Number To Decimal String function ignores those so that 1, 10, and 100 (ie. 1, 01, 001 in reverse) all come out as 1.
The other thing I tried seems to work but isn't very elegant. I took each file name and, inside a loop, concatenated an index (converted to a string) with a space at the beginning and a period at the end and used the Match function to see if it matched any part in the file name. If it didn't, the next iteration would concatenate the next index with the space and the period and search for that in the string and over and over until it found a match. Then I would know what the number was by which iteration it was on in the loop. This worked well enough, and i
t doesn't require a knowledge of the "base" part of the file name, but it is sort of a "brute force and ignorance" approach.
If you have any suggestions they would be greatly appreciated.
Thank you.
You can use a regular expression to extract the number. In the following code the top loop uses the method describe by Ben using the cluster sort. The bottom loop find the file number using a similar regex, convert the number to have 4 digits with leading zeros, replace the original number by this 4 disgits one and the sort the resulting array.
Both methods works and have their advantages/desavantages. The first one you need to unbundle to get the filenames, the second one changes the filename a bit.
Note, the left loop is just use to generate random number filenames and duplicate names are highly probable.
Ben64