Page 1 of 1

How to get the files list according to the files order in the explorer window?

Posted: 29 Oct 2020, 10:40
by jly
How to get the files list according to the files order in the explorer window?

There are a lot of files to be processed, and some explorer windows have tens of thousands or hundreds of thousands of files.


One way is:
Use the Loop Files method to get, the order of the obtained files is different from that in the window.
This also cannot get the file list in the searched window.

The file order in the file window is natural sorting,
as well as modification date, file type, file size sorting, etc.,
and various sorts are combined with natural sorting.

It is very troublesome to restore the files obtained by the Loop Files method to the original order in the explorer window!



Another way :
for window in ComObjCreate("Shell.Application").Windows
if window.HWND = WinExist("A")
. .. .this_window := window
for item in this_window.Document.Folder.Items
. .. .file_path := item.Path

This method can also obtain the file list in the searched window.
The disadvantage is that the speed of obtaining is relatively slow.
When the number of files is thousands or even tens of thousands, it will take a long time.


Is there any other better way to get the file list according to the file order in the explorer window?
Or is there any script in this regard for reference?