1

This used to be really easy in the old OS's.

dir /o:n >> list.txt
for %a in (`list.txt`) do copy %a ..\ordered

And voila, there was the list of files in the other folder, created in the sorted order. This way, when I do a regular dir ..\ordered, the files would show up in the order of their filenames.

This no longer works in the new systems. When I execute the above, the dir ..\ordered ends up showing the files in the same order as they were in the original folder.

I tried copying onto another drive. The files were copied one at a time using a script, in the alphabetical order; I even put pauses between the copies, to make sure some sort of caching didn't make them write to disk out of order. However, when I do a dir command, they again show up out of order-- this time, in a different order than they were in the original directory. However, copying to the same drive multiple times seems to result in the same order on that drive.

I checked to see what attributes the sort order on dir was based on, to see if I could touch those attributes up. I checked the following attributes

Date
Date Accessed
Date Created
Date Last Saved
Date Modified

Sorting by these attributes never yielded the same order as the dir command does.

How to override this behavior, and get a custom order when running dir?

Alex
  • 250

0 Answers0