FCPeditor wrote:
I just want to sort the front finder window by name, the code below does nothing. OS 10.10.3 any ideas?
The following solution is admittedly not the most elegant one, but it seems to do exactly what you are asking for:
tell application "Finder"
if not (existsFinder window 1) then return
activate
repeat until frontmost is true
end repeat
set current view of Finder window 1 to list view
repeat until current view of Finder window 1 is list view
end repeat
end tell
tell application "System Events" to tell process "Finder"
if existsmenu item "Show View Options" of menu 1 of menu bar item "View" of menu bar 1 then
keystroke "j" usingcommand down
end if
repeat until exists (window 1 whose subrole is "AXSystemFloatingWindow")
end repeat
tell (window 1 whose subrole is "AXSystemFloatingWindow")
clickpop up button "Sort By:"
clickmenu item "Name" of menu 1 of pop up button "Sort By:"
end tell
keystroke "j" usingcommand down
end tell