Finder Sort by Comment

Hi, i try to sort the front finder window by comment?

I wrote/copied together some ideas in variations from this platform (http://macscripter.net/viewtopic.php?id=44439)
and other sites.

From what i read i understood, there is a Problem with refreshing the Finder Window.
I define the comment column as the sort column, but if the window reopens ist sorted by Name.

Is there a Way to to it?

Thanks for response.

Here ist my example…

tell application "Finder"
	tell Finder window 1
		set current view to list view
		tell its list view options
			set properties to {calculates folder sizes:false, shows icon preview:false, icon size:small icon, text size:10, uses relative dates:true} --, sort column:comment column, sort direction:normal}
			
			tell column name column
				set properties to {index:1, sort direction:normal, width:20}
			end tell
			tell column size column
				set properties to {index:8, sort direction:normal, width:72, visible:true}
			end tell
			tell column modification date column
				set properties to {index:6, sort direction:normal, width:120, visible:true}
			end tell
			tell column creation date column
				set properties to {index:4, sort direction:normal, width:120, visible:true}
			end tell
			tell column kind column
				set properties to {index:5, sort direction:normal, width:120, visible:false}
			end tell
			tell column label column
				set properties to {index:2, sort direction:normal, width:72, visible:true}
			end tell
			tell column version column
				set properties to {index:7, sort direction:normal, width:72, visible:false}
			end tell
			tell column comment column
				set properties to {index:3, sort direction:normal, width:100, visible:true}
			end tell
			
			set sort column to comment column
			tell sort column
				set sort direction to normal -- normal | reversed
			end tell
			
		end tell
		--tell application "Finder" to tell front window to update every item
	end tell
	
	tell the front Finder window
		--set current view to list view
		--set zoomed to false
		set f to target 
		close 
	end tell
	
	open f 
end tell

Model: MacBook
Browser: Safari 537.86.4
Operating System: Mac OS X (10.9)

Hi. Welcome to MacScripter.

I haven’t found a way to make the columns’ visibilities take, but on my machine (10.11.3), the size and sort column changes become visible if the window’s closed and opened twice.


tell application "Finder"

	-- Set the properties as previously, then:
	
	set f to target of front Finder window
	repeat 2 times
		close front Finder window
		open f
	end repeat
end tell

Hi Nigel,
Thanks for your Feedback.

Unfortunately that’s not the solution, the result remains the same.
It seems that when you open a window, the priority of the sort is on the Name column.

No success by observing the notes of this entry: http://macscripter.net/viewtopic.php?id=41761
Tried tom take out to address the name column…

the same @ 10.10.5

Martin

set altTarget to path to favorites folder
tell application "Finder"
	if front window exists then
		set _target to target of front window as alias
		if _target = altTarget then set altTarget to path to home folder
		tell front window
			--set bounds to {0, 44, 1040, 1196} # Must be less than the aggregate column widths.
			if current view ≠ list view then
				set current view to list view
			end if
			tell its list view options
		set properties to {calculates folder sizes:false, shows icon preview:false, icon size:small icon, text size:10, uses relative dates:true} --, sort column:comment column, sort direction:normal}
				(*
					tell column name column
						set properties to {index:1}, sort direction:normal, width:20}
					end tell
				*)
				tell column size column
					set properties to {index:8, sort direction:normal, width:72, visible:true}
				end tell
				tell column modification date column
					set properties to {index:6, sort direction:normal, width:120, visible:false}
				end tell
				tell column creation date column
					set properties to {index:4, sort direction:normal, width:120, visible:false}
				end tell
				tell column kind column
					set properties to {index:5, sort direction:normal, width:120, visible:false}
				end tell
				tell column label column
					set properties to {index:2, sort direction:normal, width:72, visible:true}
				end tell
				tell column version column
					set properties to {index:7, sort direction:normal, width:72, visible:false}
				end tell
				tell column comment column
					set properties to {index:3, sort direction:normal, width:100, visible:true}
				end tell
				
				set sort column to comment column
				tell sort column
					set sort direction to normal -- normal | reversed
				end tell
				
			end tell
			repeat 2 times
				set target to altTarget
				set target to _target
			end repeat
		end tell
	end if
end tell

I don’t know what to suggest then. It does work for me, except for making hidden columns visible and vice versa. The items are sorted by comment in the window even when the comment column isn’t visible. However, where several files have the same comment, they’re then subsorted by name, whatever the sort column was before. But you’re apparently using Mac OS 10.9, so maybe the behaviour’s different on that system.

Coming back to post this, I see you’ve extended your reply with a script which doesn’t reopen the window at all! Here’s what I was using:

tell application "Finder"
	tell Finder window 1
		set current view to list view
		tell its list view options
			set properties to {calculates folder sizes:false, shows icon preview:false, icon size:small icon, text size:10, uses relative dates:true} --, sort column:comment column, sort direction:normal}
			
			tell column name column
				set properties to {index:1, sort direction:normal, width:20}
			end tell
			tell column size column
				set properties to {index:8, sort direction:normal, width:72, visible:true}
			end tell
			tell column modification date column
				set properties to {index:6, sort direction:normal, width:120, visible:true}
			end tell
			tell column creation date column
				set properties to {index:4, sort direction:normal, width:120, visible:true}
			end tell
			tell column kind column
				set properties to {index:5, sort direction:normal, width:120, visible:false}
			end tell
			tell column label column
				set properties to {index:2, sort direction:normal, width:72, visible:true}
			end tell
			tell column version column
				set properties to {index:7, sort direction:normal, width:72, visible:false}
			end tell
			tell column comment column
				set properties to {index:3, sort direction:normal, width:100, visible:true}
			end tell
			
			set sort column to comment column
			tell sort column
				set sort direction to normal -- normal | reversed
			end tell
			
		end tell
		--tell application "Finder" to tell front window to update every item
	end tell
	
	set f to target of front Finder window
	repeat 2 times
		close front Finder window
		open f
	end repeat
end tell

Ok,

successfully tested under 10.6.8 and 10.11.
does not work under 10.9 and 10.10

:frowning:

After several tests, I found the Bug.
AppleScript sorts the comment column based on the modification date column.
Its the same pattern. So i think there is no chance for an workaround.

danke und gruss
Martin