Sorting Finder windows doesn't work anymore?

Is it just me - or sorting Finder windows by specific column doesn’t work anymore?

I’m pretty sure it worked years ago.

The following script doesn’t seem to work - kind of:

tell application "Finder"
	tell front window to set the current view to list view
	
	tell list view options of front window
		set sort column to column modification date column
	end tell
end tell

That is, it appears that the script just DOESN’T REFRESH the window in the Finder.

If you try to return the “sort column” value it DOES return “column modification date column”.

If you close the window, then open - the sort column WILL be changed to Date Modified.

So if you add commands to close, then open the window again at the end of the script - the desired result will be achieved.

I have the same issue on both Mojave and Catalina.

I also submitted bug to Apple.

I wonder if others have the same experience?

Thanks,
Leo

Hi.

I’m afraid it’s been like that for quite a while now. :frowning:

An alternative to closing and reopening the window is to switch its target temporarily. This can have a less clunky visual effect, but is no good if the view you want to change is for the “other folder”!

set otherFolder to (path to home folder)

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

Thanks for the tip, Nigel!

That’s indeed better.

Nigel. I ran your script and I frequently get the error message that:

I checked and double checked and the modification date column (“Date Modified”) is visible. I changed “modification date” to “name” and the script worked every time. The Finder has never been very reliable when doing this sort of stuff, and I assume that’s the case here.

BTW, changing folders to refresh is much better than closing and opening the Finder window, and I’ve changed my Finder-reset script. Thanks.

EDIT: FWIW, I went back to closing and opening the Finder window to refresh because that tended to set the changes the script made while changing folders did not. Some people may not want the changes remembered but I do.

Hi peavine.

I haven’t come across that problem myself. Are there any other particular circumstances when it occurs, such as a particular previous view or column setting, with many or few items showing in the window, or with the Finder frontmost or not?

When a script asks for the current sort column, the result has the keyword id in it, as in:

Is the script any more reliable with set sort column to column id modification date column ?

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: