Sorting Finder windows doesn't work anymore?

Nigel. Adding “id” did not make a difference.

I ran the script on a folder and got the error message I note earlier. I then immediately ran the following script:

tell application "Finder"
	tell front Finder window
		tell its list view options
			set sortColumn to sort column
		end tell
	end tell
end tell

And this script returned:

column id modification date column of list view options of Finder window id 982 of application “Finder”

So, the modification-date column is there.

I ran the script directly from Script Editor and then by way of Fastscripts and still got the error message.

I tried to find a pattern when the script worked and when the error message was issued but couldn’t discern anything.

Anyways, I always sort to the name column, which works 100 percent of the time, so I’m sure there’s something odd about my computer. My computer has never been the same since installing Catalina, even after going back to Mojave, so I’ll blame it on Catalina. :slight_smile:

Hmmm. A mystery. :confused:

I’ve no plans to install Catalina myself. The blurb on Apple’s site says “The apps you use every day, made extraordinary.” But according to the nags I get from Mojave, the apps I use every day will simply be rendered unusable! Apart from that, I don’t need even better synchronisation with my non-existent iPhone, iPad, Apple Pencil, Apple Watch, or iCloud account. I’ve no wish to instant-message anyone, send movies of myself to them, co-author notes with them, or listen to their podcasts. I have proper equipment for watching television and playing music. I don’t need yet more ways of viewing and organising things I can see perfectly well already. Dark Mode palls after a couple of hours. I don’t talk to computers. Etc. etc.:wink: Equally, though, I won’t be able to test Catalina-specific issues when they crop up here. :confused:

Visible property of columns of Finder window doesn’t mean visible to eyers, but permission or not for changing its value. So, to get script without error, set firstly visible of particular column to true. Column name is visible always. Nigel Garvey has visible of modification date column = true, but Peavine has it = false. This is why they got different results.

Hmmm. Thanks, KniazidisR. That looks like another bug in the Finder’s scripting implementation. I’m sure that setting a column’s ‘visible’ property to false should hide the column, but it doesn’t — not in Mojave, anyway. And while a column whose ‘visible’ is returned as false in AppleScript can’t be set as the sort column in a script, it can at the same time be visible to the user and set as the sort column manually.

Also, although I was initially able to script the ‘visible’ of my test folder’s modification date column to false for testing, now that I’ve been fooling around with both manual and script settings for a while, the AppleScript setting is now stuck on true. It remains true whether I set it to false in a script, hide the column manually, or both. In this situation, the scripts above never error. If an instruction explicitly setting the modification date column’s ‘visible’ to false is inserted before the one to set the column as the sort column, the ‘visible’ remains true and the column is made the sort column. If the column’s actually hidden when the scripts are run, the line setting it as the sort column is simply ignored. Manually restoring the window to its initial state (list view, sorted by name, modification date column visible, window closed) and restarting the computer hasn’t restored the ability to change the ‘visible’ setting of that window’s modification date column by script. :confused:

I think KniazidisR may be partially correct but the question is what to do about it.

I run the following to change the visible status:

tell application "Finder"
	tell front Finder window
		tell its list view options
			set visible of column id modification date column to true
		end tell
	end tell
end tell --> true

I then then run Nigel’s script from his post earlier in this thread and it errors the same as before. I then run the following which should return true but instead returns false:

tell application "Finder"
	tell front Finder window
		tell its list view options
			set visibleStatus to visible of column id modification date column
		end tell
	end tell
end tell --> false

I raised this issue over a year ago in:

https://macscripter.net/viewtopic.php?id=46755

I agree with Nigel that the Finder seems broken in this regard.

Tried to set visible in the same script of Nigel, in the one entire script?
I tried the following and it works for me fine:


set otherFolder to (path to home folder)

tell application "Finder" to tell front Finder window
	set the current view to list view
	
	tell its list view options
		set visible of column id modification date column to true
		set sort column to column id modification date column
	end tell
	
	set targetFolder to target
	set target to otherFolder
	set target to targetFolder
end tell

KniazidisR. I ran your script and received the same error as before:

BTW, I thought deleting the .DS_Store file might make a difference but it didn’t.

Peavine, I already said that the visible property does not control the visibility of the “Data modified” column by eye. You have to right-click on the your folder, go to Show View Options and set the checkbox “Data modified”. Manually. And only then run the script. I improved it:


set aFolder to choose folder

tell application "Finder"
	activate
	open aFolder
	
	tell front Finder window
		tell its list view options
			set visible of column id modification date column to true
			set sort column to column id modification date column
		end tell
		close it -- close window, and soon open again to see changes
	end tell
	
	open aFolder
end tell

I did that a long time ago and still got the error message. I just did it again and ran the script and I still get the error message. BTW, I assume you mean “Date Modified” not “Data Modified”.

Try to run my script. There is no switch to the “other, home folder”. I hope the column “Date Modified” is present in the folder you select, and there is no confusion with the “other, home folder”.

I ran the new script and got the same result. I checked and the folder I selected had the Date Modified column showing. I viewed the show view options and there is a check mark next to Date Modified. The script returns the same error. I don’t know what you mean by “other,home folder”.

There’s no point in arguing, fellas. As I noted in post #9, the value of the column’s AppleScript ‘visible’ can become fixed and ignore further script comands to change. With me, it stuck on true. With peavine’s column it’s apparently stuck on false. With KniazidisR’s column, it hasn’t (yet) stuck at all. We’re all using the same script and experiencing different things.

Nigel. I wouldn’t say we were arguing–just trying out different stuff. I agree that ‘visible’ can become stuck, and running and rerunning scripts isn’t going to change that. I’ll accept this as a mystery and move on. :slight_smile:

mystery… indeed. One time I was able to change visible property value, but I forgot how :slight_smile: This happened about 2 months ago. Now, its value on my machine is stuck on true, as with Nigel’s machine… As I remember, I experimented with delete column and make column commands 2 months ago

Annoyingly, I thought I’d got the ‘visible’ of my test folder window’s columns working again this morning, but it’s now stuck again. :mad:

Some more weird stuff:

tell application "Finder"
	tell front Finder window
		tell its list view options
			get name of columns
			count columns
			count (columns whose name is name column)
			count (columns whose name is modification date column)
		end tell
	end tell
end tell
return

Running this script against list view windows which haven’t been subjected to the column-changing scripts above, I get the expected results in Script Editor’s “Replies” pane:

But with the window of the test folder I’ve been using:

Just to give an historical reference, here, under 10.13.6 Finder behaves as described by KniazidisR.
Starting with this state:


(*
get visible of column creation date column of list view options of Finder window 1
		--> false
get visible of column name column of list view options of Finder window 1
		--> true
get visible of column modification date column of list view options of Finder window 1
		--> true
get visible of column creation date column of list view options of Finder window 1
		--> false
get visible of column size column of list view options of Finder window 1
		--> true
get visible of column kind column of list view options of Finder window 1
		--> true
get visible of column label column of list view options of Finder window 1
		--> false
get visible of column version column of list view options of Finder window 1
		--> false
get visible of column comment column of list view options of Finder window 1
		--> false
*)

If I ask Show presentation options to make the column creation date visible, the script continue to return the visible value as false (even after a close - reopen process).
If I ask the script to set the visible of the column creation date to true, the script correctly returns the value.
If I ask Show presentation options to make the column creation date hidden, the script continue to return the visible value as true (even after a close - reopen process).
It appears that the broken link between the true behavior and AppleScript is not a new feature.

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) dimanche 27 octobre 2019 15:24:35

No, Yvan, I wrote a small script here to quickly experiment with different folders:


set aFolder to choose folder

tell application "Finder"
	set aWindow to container window of aFolder
	tell aWindow to tell its list view options
		set visible of its column id modification date column to true -- then, I tested here with false
		set isVisible to get visible of its column id modification date column
		set sort column to its column id modification date column
	end tell
end tell

The results were even more unexpected for me. It turns out that Finder divides folders into 3 types:

  1. Folders for which the VISIBLE property is hardcoded to TRUE. (for example, mine PICTURES folder).
  2. Folders for which the VISIBLE property is hardcoded to FALSE. (for example, mine HOME folder).
  3. Folders for which the VISIBLE property is not hardcoded and can be set to TRUE or FALSE. (for example, all folders of the root directory and the root directory itself).

This leads me to a strange thought that the behavior of the VISIBLE property is related to folders privileges…

NOTE: So far, I have only found 2 hardcoded folders on my Mac: HOME folder and PICTURES folder. Even with their subfolders, VISIBLE property works fine. You can set it to TRUE/FALSE and Finder doesn’t ignore new setting.

I apologizes but here the different kinds of windows which you described behave exactly the same way.

I tested with :

tell application "Finder" to tell Finder window 1 to tell its list view options
	repeat with colName in (get name of every column)
		set origState to get visible of column colName
		log origState
		if colName as text is "modification date column" then
			set visible of column colName to not origState
			log (get visible of column colName)
		end if
	end repeat
end tell

At first pass the log report was :

(*
tell application "Finder"
	get name of every column of list view options of Finder window 1
	get visible of column name column of list view options of Finder window 1
	(*true*)
	get visible of column modification date column of list view options of Finder window 1
	(*false*)
	set visible of column modification date column of list view options of Finder window 1 to true
	get visible of column modification date column of list view options of Finder window 1
	(*true*)
	get visible of column creation date column of list view options of Finder window 1
	(*true*)
	get visible of column size column of list view options of Finder window 1
	(*true*)
	get visible of column kind column of list view options of Finder window 1
	(*true*)
	get visible of column label column of list view options of Finder window 1
	(*false*)
	get visible of column version column of list view options of Finder window 1
	(*false*)
	get visible of column comment column of list view options of Finder window 1
	(*false*)
end tell
*)

At second pass it was :

tell application "Finder"
	get name of every column of list view options of Finder window 1
	get visible of column name column of list view options of Finder window 1
	(*true*)
	get visible of column modification date column of list view options of Finder window 1
	(*true*)
	set visible of column modification date column of list view options of Finder window 1 to false
	get visible of column modification date column of list view options of Finder window 1
	(*false*)
	get visible of column creation date column of list view options of Finder window 1
	(*true*)
	get visible of column size column of list view options of Finder window 1
	(*true*)
	get visible of column kind column of list view options of Finder window 1
	(*true*)
	get visible of column label column of list view options of Finder window 1
	(*false*)
	get visible of column version column of list view options of Finder window 1
	(*false*)
	get visible of column comment column of list view options of Finder window 1
	(*false*)
end tell

I repeat that I get this behavior under 10.13.6 (my iMac refuse more recent system).

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) dimanche 27 octobre 2019 20:51:05

I’ve been looking into this further with the thought of submitting a bug report. But it’s not at all clear how to tailor it to Apple’s bug reporting protocol, or even how many bugs are involved! I’ve also run the same tests on my El Capitan (10.11.6) machine to see if there are any differences. For anyone who’s interested, or who doesn’t mind being strangled to death by their own intestines, here’s what I’ve found:

• In both El Capitan and Mojave, scripted changes in a Finder window’s ‘list view’, ‘icon view’, or ‘column view’ options have no visible effect until the window’s either closed and reopened or its ‘target’ is switched to another folder and back. However, the new values are correctly returned to scripts.

• There are no scriptable view options for the “Cover Flow” view which exists in El Capitan or for the “Gallery View” which exists in Mojave. On both systems, though, a window can be scripted to switch instantly to the relevant view by setting its ‘current view’ to ‘flow view’. The Finder dictionaries on both systems also offer a ‘group view’. In El Capitan, this compiles as is but errors when run. In Mojave, it recompiles as ‘flow view’ and changes the view to Gallery View! This ‘group view’ setting has no connection with the Toolbar button labelled “Group By” in Mojave or “Arrange By” in El Capitan.

• On both systems, if a Finder window’s ‘sort column’ in list view is the same as its ‘arrangement’ in icon view (eg. ‘sort column’ = ‘column modification date column’ and ‘arrangement’ = ‘arranged by modification date’), changing the ‘sort column’ by script also changes the ‘arrangement’ to a matching setting. This doesn’t happen when the sort column is set manually or when the views’ sorting arrangements are different to begin with. Changing an icon view’s ‘arrangement’ by script doesn’t change the list view’s ‘sort column’. The term ‘arranged by’ in the icon view options is to do with sorting, not with what El Capitan’s Toolbar button calls “Arrange By” or Mojave’s calls “Group By”.

• On neither system does changing a list view column’s ‘visible’ setting have any effect on the number of columns visible in the window. The width of other columns may be changed in El Capitan, but in Mojave there’s no visible effect at all. In Mojave, though, each time a script sets a column’s ‘visible’ property, the number of columns subsequently returned to scripts doubles. The extra columns are all zero-width ‘name’ columns at the beginning of the returned list. The number of columns, initially 8, maxes out at 256, whereafter it becomes impossible to change any of the columns’ ‘visible’ values ever again. Attempts to change the ‘name’ column’s ‘visible’ to ‘false’ correctly raise errors, but commands setting the ‘visible’ of other columns are simply ignored. This means that if a column’s last successful ‘visible’ setting was to ‘false’, it can never again be scripted to be the sort column. This appears to be permanent for the folder to which the view belongs, but only affects Finder AppleScripting. It’s still possible to do whatever’s necessary manually in the GUI. It’s also still possible to script changes to the columns’ sort directions, even if they’re neither visible nor the sort column as far as AppleScript’s concerned. While the number of columns returned to a script can be up to 256, commands which count them directly (as opposed to counting the returned list) only see eight. Similarly, it’s not possible to use an index specifier higher than 8 to address them and ‘whose’ filters only return matches from the first eight columns.

As an experiment, I copied a “256 column” folder over my network from my Mojave machine to my El Capitan one. The El Capitan Finder also returns 256 columns from the folder window’s list view options — but there are no invisible files in the folder, so it’s not clear how this information has been conveyed. The widths of the additional ‘name’ columns are returned as 457 instead of 0. The other columns’ ‘visible’ properties can be changed in El Capitan, but the eight-column limit still applies for counts, index references, and ‘whose’ filters.

It’s time for another coffee!

I filed it under Developer Tools and only reported that changing sort columns in the Finder using AppleScript doesn’t work on Mojave and Catalina.

I included a simple AppleScript example and also mentioned that it worked a few years ago.

I think it’s all they should be concerned with!