Jump to content
Macro Express Forums

Repeat with Folder: sorting / order of files


Recommended Posts

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!

Link to comment
Share on other sites

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.

 

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...