MakaPakaTobyHannah Posted March 3, 2011 Report Share Posted March 3, 2011 I've constructed a simple macro to display all *.TXT files in a given directory by listing them, one by one, through a string variable (using carriage returns and line feeds) displayed in a text box, using the "Repeat with Folder" command. The order in which the files appear is: 01.TXT 02#034B.TXT 02.TXT 02A.TXT 28A.TXT 100ABC#D.TXT 201.TXT Yet the order in which the files are processed (and then displayed) is: 01.TXT 02#034B.TXT 02.TXT 02A.TXT 100ABC#D.TXT 201.TXT 28A.TXT That is, 28A.TXT has moved to the bottom of the list. Is this a known issue? Am I missing something? Curious if someone has the solution to this.... thanks! Quote Link to comment Share on other sites More sharing options...
Cory Posted March 3, 2011 Report Share Posted March 3, 2011 There are different methods of sorting and MEP is using a different one than your Windows Explorer. I often find the same problem between a command prompt and Windows Explorer. In this case it's 'seeing' the number inherent and being clever figuring out that 100 is greater than 28. But if one evaluates character by character you will see MEP it technically correct because 1 is less than 2. In any case Windows is the one reporting the files to MEP in this order so the programmers of MEP are handing it to you in that order. All you can do is create your own search algorithm and sort to your liking. Quote Link to comment Share on other sites More sharing options...
paul Posted March 4, 2011 Report Share Posted March 4, 2011 If you have any control over how the text files are named, then try using 001.txt, etc. so that all file names have a numeric component of the same length. So if your largest number were 1000, then it would be 0001.txt. Quote Link to comment Share on other sites More sharing options...
MakaPakaTobyHannah Posted March 4, 2011 Author Report Share Posted March 4, 2011 Thanks, Cory and Paul, helpful at least to confirm that it wasn't down to something I was missing or doing wrong. Odd indeed that Windows File Explorer would list these files in lexicographic order (e.g. file1, file10, file2, file20 file3 ... ) but that the operating system would report them in numerical order (e.g. file1, file2, file3,...,file10, file11,...,file20) - I think that's the difference. Both sorting methods are perfectly fine and "correct" - it is a question of preference. Paul's suggestion is spot on: and that's really wny I created this macro. It is meant to deal with situations where the nomenclature of these files is NOT as Paul suggests; in other words, using Paul's nomenclature obviates the need for which I designed the macro. I havent' checked yet to see if the sorting of files in CMD is different from file explorer, as Cory seems to have observed. That would be bizarre indeed. One remaining option I will try is to call CMD in a hidden session from the macro, invoking its own "SORT" command on the file list, and then to see what pops out... anyhow, that's good enough for me. Cheers, Jürgen Quote Link to comment Share on other sites More sharing options...
paul Posted March 4, 2011 Report Share Posted March 4, 2011 Odd indeed that Windows File Explorer would list these files in lexicographic order (e.g. file1, file10, file2, file20 file3 ... ) but that the operating system would report them in numerical order (e.g. file1, file2, file3,...,file10, file11,...,file20) - I think that's the difference. Both sorting methods are perfectly fine and "correct" - it is a question of preference. Take a look at this registry setting - I think it will solve your problem. Sorting in Explorer Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.