Is there an axiomatic way to sort a Finder window (in column view) by name in ascending order?

ChatGTP and I have become great friends on account of my total ignorance regards the grammar (dare I call it something as simple as syntax!) rules required to AppleScript with any proficiency.

We spent half an hour trying to do the seemingly simple task of opening a window in column view (check) and then sorting it by name (ascending).

The Finder dictionary tells me this should be a valid and simple request (no surprises there):
sort column (column) : the column that the list view is sorted on

But all our attempts to invoke(?) this property including trying to do an
osascript -e 'tell application \"Finder\" etc from a do shell script met with failure

Would love to know what I’m not getting here.

Thanks in advance, I used to be able to script Adobe products a little bit where require and where automated Adobe Actions couldn’t do it, maybe 15 years ago and never really loved the language… expressive and “natural language reading” as it can be. ChatGTP is my only hope to write Applescripts, I’m already overcommitting time on scripts that aren’t worth the time I’m investing in them!

There’s a bug in Finer’s AppleScript support. Sorting commands don’t work.

I submitted this bug to Apple in 2019.

I don’t know if there are any workarounds for this.

1 Like

I’m able to get it working by closing and re-opening the window, e.g.:

tell application "Finder"
	set theTarget to target of window 1
	tell list view options of window 1
		if name of sort column is name column then
			set sort column to kind column
		else
			set sort column to name column
		end if
	end tell
	close window 1
	open theTarget
end tell

It’s kinda hacky but it works (on Sequoia 15.1). Also, this script only works for windows in list or icon view, but you could fix that by adding some checks and storing/restoring the state.

1 Like

oh yeah now i remember… that’s the workaround!

1 Like