0

As you can know, you can sort files in windows explorer by their names, But it seems VBScript is not showing them in sorted way.

Here is a sample script which show file names in a folder one by one

Set objFSO = CreateObject("Scripting.FileSystemObject")
strReg = "C:\Users\Smart\Desktop\Files"
Set objFolder = objFSO.GetFolder(strReg)
Set colFiles = objFolder.Files
For Each objFile in colFiles
    WScript.Echo ObjFile.Path
Next

But it seems it is showing files in random ways. How Can I edit this script to show files just as they are sorted in windows explorer?

Just note that My Files' Names are unicode

Inside Man
  • 4,194
  • 12
  • 59
  • 119

1 Answers1

1

As the FileSystemObject can't sort the files (cf. the citation here), you'll have to write (not edit) your own code. Start here for a sample using an ArrayList (and a list of alternative approaches). The first link shows how to use dir /A:-D /B /O:....

Community
  • 1
  • 1
Ekkehard.Horner
  • 38,498
  • 2
  • 45
  • 96
  • Thank You, I tested your second link's Script. But it seems it can not sort files just like windows explorer. What should I do? Your script is working just my script. It is listing files as they are listed my script! – Inside Man Oct 17 '14 at 15:04