Quantcast
Viewing all articles
Browse latest Browse all 16609

Items list: Default sort order

You could create a script that runs for specific groups (or all groups) that updates the sort order through GUI scripting. It’s not the best, but if you want to (re)set a sort order every once in a while it works fine. The sortOption has to specificed in the exact way it appears in the menu (including capitalization).

Be aware this resets the sorting for all groups; if you want to exclude certain groups (or e.g. a specific sort that you always want to keep) you have to edit the script. E.g. this script looks at groups from the current database, but excludes ordinary tags.

tell application id "DNtp"
	try
		set theGroups to every parent of current database whose tag type is not ordinary tag
		repeat with theGroup in theGroups
			set root of viewer window 1 to theGroup
			my setSorting("by Kind")
		end repeat
	on error error_message number error_number
		if the error_number is not -128 then display alert "DEVONthink" message error_message as warning
	end try
	
end tell

on setSorting(sortOption)
	tell application id "DNtp"
		activate
		tell application "System Events"
			tell process "DEVONthink 3"
				click menu item sortOption of menu 1 of menu item "Sort" of menu "View" of menu bar 1
			end tell
		end tell
	end tell
end setSorting

Unfortunately the “On Open” action for smart rules doesn’t trigger when changing groups in DT afaik, but @BLUEFROG or @cgrunenberg might be able to comment if there are other possibilities to trigger this.


Viewing all articles
Browse latest Browse all 16609

Trending Articles