Suggestion: add workspaces to sidebar, make dynamic

Something like this? It’s a script fork from your own script here Script to select workspace

I just add a few lines. After u choose a workspace from your list, one more dialogue to ask whether u want to save or load the selected workspace. (1) It seems there is no command to create workspace by script though. So u can only choose to load or save existing workspaces. If this is not what u need, my apology. (2) I haven’t fully tested the script…

EDITED. It seems that ur original script does not close all existing think windows before loading a workspace. Therefore, I just added one more line to close all current think windows before loading the workspace (for “Load” action only).

One more suggestion. Create N dummy files, each named as one of your workspace. Put them under “Favourites”. Since the name of the dummy files are the same as the workspaces, just add two more lines of script (1) un-flag or un-label all dummies (2) label or flag the dummy file with the same name as the selected workspace (“set the label of record at “/…/…/dummyname” to 1” or something like that). That way you will always know which workspace is activated.

use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions


tell application id "DNtp"
	try
		set theWorkspaces to workspaces
		choose from list theWorkspaces
		if the result is not false then
			set theSelection to item 1 of the result
			set action to text 1 of button returned of (display dialog ("Choose action") with title "Load or update workspace" buttons {"Cancel", "Load", "Save"} default button 2)
			if action is "L" then
                close every think window
				load workspace theSelection
			else if action is "S" then
				save workspace theSelection
			end if
		end if
	end try
end tell

Another very quick and dirty script to create a list of dummy files in a location chosen by you that named the same as all workspaces. With this, you don’t have to manually create the dummies…

tell application id "DNtp"
	
	set ws to workspaces
	set l to {}
	set theWSDummyLocation to display group selector "Create the dummmy files in:" for current database
	repeat with i from 1 to length of ws
		set theNewDoc to create record with {name:(item i of ws) as string, source:"" as string, type:rtf} in theWSDummyLocation		
	end repeat
	
end tell