• Status: Solved
  • Priority: Low
  • Security: Public
  • Views: 50
  • Last Modified:

Explorer.exe Command line argument to sort by name?

This question is very minor, but I am sometimes willing to waste an hour or two just to avoid a two second annoyance once or twice a day.  (It's just one of those personal quirks that some of us have.)


Our company's shared root directory has many folders.

\\Root\aafolder1\
\aafolder2\
...\bunches of other folders\..
\projects for bob
\projects for sam
\projects for randi
....\way more folders

My desktop has the following Windows shortcut  which opens explorer with my own "Projects for Bob" folder selected.

    shortcut target:       C:\Windows\explorer.exe /select,"\\Root\Projects for Bob"

If I want to view someone else's projects, I double click the icon, then use arrowup or arrowdown to the desired folder & hit enter.

But, it only works if \\Root is sorted by name, which is often not the case.  While it only takes one additional click to sort it by name, I still find it annoying.

As far as I can tell explorer.exe does not have a command line parameter to sort the directory.  I believe sorting is tucked away in the \\root\Thumbs.db file along with other view properties.  

Does anybody have a suggestion of how to control this?  Perhaps a vbs script like this:
    shortcut target:       C:\MyCommands\MAGICSRIPT.VBS /select,"\\Root\Projects for Bob"

I know how to get vbs to open a folder using objShell.Explore strPath , but I can't figure out how to change the sorting sequence.
0
rberke
Asked:
rberke
  • 3
  • 2
  • 2
1 Solution
 
JohnBusiness Consultant (Owner)Commented:
Windows Explorer can set the View to the Current Folder settings, but the Sort sequence can be easily changed and there is no default setting for that.

Consider using xPlorer2 (Zabkat) if you want detailed settings retained.
0
 
Bill PrewCommented:
Windows should remember the last sort column and order for a folder, so each time you open it with the shortcut it should always be the same.  Unless you change it for some reason, and if so just make sure you always put it back to Name when done.


»bp
0
 
JohnBusiness Consultant (Owner)Commented:
Agree. Setting hold until changed. I see lots of user changing Windows Explorer settings on the fly.
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
rberkeConsultantAuthor Commented:
Bill:

Keep in mind, am only trying to avoid a two second annoyance once or twice a day.

The fact that windows holds the setting does not help me at all: I often change the folder sequence to be sorted by Date of Last Modification. Afterwards, I could return Sort by Name but that would also be a two second annoyance one or twice a day.  

Also, it is not just one directory for my own personal use. My company has a standard list of useful shortcuts that appear in every user's quicklaunch toolbar.  Almost all of those shortcuts work best if the target folder is sorted alphabetically.

John,

At the moment, I think you have the Best Answer. Namely "Explorer does not have any command line sorting option. A 3rd party software solution would be necessary."

Nonetheless, I will leave this question open a few more days in the hopes that someone can come up with a vbscript or possibly an AutoHotkey solution.

rberke
0
 
Bill PrewCommented:
Well, you could feel Explorer keys once it opens, but the problem with trying to control sort order this way is sorting toggles when you invoke a column, so if you were already sorted by Name Ascending, then the same keys the next time you enter will switch it to Name Descending.  Not sure any way to work around this, but here is a small test VBS if you want to experiment a bit...

With WScript.CreateObject("WScript.Shell")
    .Run "explorer /select,""c:\temp""", 1, False
    WScript.Sleep 2000
    .SendKeys "%VO"
    .SendKeys " "
End With

Open in new window


»bp
0
 
rberkeConsultantAuthor Commented:
Bill, I solved the Ascending/Descending toggle by first sorting by date time. So, it now does exactly what I wanted.

My shortcut has target: C:\CompanyCode\ExploreSort.vbs "\\Root\aafolder1\Transfer to Bob"

Unfortunately, every time I run, the screen flashes for about 4 seconds which is also annoying.  As far as I know, vbscript does not have a screenupdating property to turn off.




filename = WScript.Arguments(0)
cmd = "C:\Windows\explorer.exe /select,""" & filename & """"
With WScript.CreateObject("WScript.Shell")
    .Run cmd, 1, False
    WScript.Sleep 2000
    .SendKeys "%VO{Down}"
    .SendKeys "{Enter}"
    .SendKeys "%VO"
    .SendKeys "{Enter}"
End With
0
 
rberkeConsultantAuthor Commented:
So, I have satisfied myself that there is no ideal solution to this minor problem.  It is time to close the thread and award points.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

  • 3
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now