Close all windows ... except current one

I know how to close all windows including save and close all document windows.
Is there a way to close all windows except the current one ?
thank you

Hi @rufus123, this does it

-- Close think windows 2 thru -1

tell application id "DNtp"
	try
		set theWindows to think windows
		
		repeat with i from 2 to (count theWindows)
			close item i of theWindows
		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
		return
	end try
end tell

2 Likes

thanks very much !
To create a script which reflects my workflow
1- first saves and closes all document windows
2- than closes all other windows except the current one
can I insert @BLUEFROG 's save and close document windows AppleScript into your own, perhaps right after the first line tell application id “DNtp” ?

tell application id "DNtp" to close every document window saving yes

Not sure but I think you can append saving yes to the “close” line

close item i of theWindows saving yes

1 Like

thanks very much !

1 Like

Closing all windows?
And saving in them?

One line:

tell application id "DNtp" to close every think window saving yes

… except current one :wink:

Mine was addressing the other scenario of just closing and saving all windows.

1 Like

@BLUEFROG @pete31
Does the notion of save and close windows exist apart form document windows ?

Sure, the scripts use think windows which means document windows plus viewer windows (which are “main” windows ).

which are “saved” and accessible where after they are closed ?

When you run the script it saves the record that is opened in the window, not the window itself.

It’s the same as pressing ⌘S and ⌘W

1 Like

OK . thank you very much Pete

Where do I paste this script? I know, I should know where to look up the information. :roll_eyes:

  1. Paste it into a new script in /Applications/Utilities/Script Editor.
  2. Select Run > Compile.
  3. Save the file. In the Save dialog, press Command-Shift-G and paste: ~/Library/Application Scripts/com.devon-technologies.think3/Menu and save to whatever subfolder you want. The script will now be accessible in DEVONthink’s Script menu.

Jim, I somehow intuited what you meant and followed your directions. Thank you! I have two ounces more computer confidence.

Glad to hear it! :slight_smile: