Jump to content

How to change a Finder window's "Sort By" option in workflow?

Recommended Posts

Finder's scripting definitions seem to allow for sorting (so no GUI scripting, but AppleScript nonetheless).



sortv : Return the specified object(s) in a sorted list

sort specifier : a list of finder objects to sort

by property : the property to sort the items by (name, index, date, etc.)

→ specifier : the sorted items in their new order


You can see the documentation via Script Editor (App), File > Open Dictionary (⇧⌘O) > Finder (from the list). 

By the by, Vitor has a neat workflow to open AppleScript Dictionaries.

Link to comment
  • 2 months later...

I occasionally find that "Sort By" has default shortcuts.



So I can use keystroke simulation via AppleScript:

tell application "System Events"
    key code 21 using {command down, option down, control down}
end tell

Maybe activate Finder first if it's necessary in your workflow.


Finder's scripting definitions, which zeitlings mentioned, may be more elegant, but I'm not very familiar with AppleScript.

Link to comment
On 10/18/2023 at 10:55 PM, sepulchra said:

I think you should be able to do this two ways without any scripting @addEdgeBookmarkSearch


1. Automation Task called "Click Menubar Item in Frontmost App."

2. Dispatch Key Combo object for each shortcut

Thank you for your advice! After my verification, both of these methods work and are more elegant! Thanks to the Alfred development team for creating such great software!


It seems I need to systematically learn the new features of Alfred so that I can use it more effectively.🥹

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...