Script: Create bookmark or alias on desktop

This script creates links to records on the desktop.

It can be set up to create only bookmarks, only aliases or to have the choice with choose from list.

I have used @korm’s excellent script for years, later modified his idea as I wanted options for creating aliases and using selected text for renaming. After reading this thread I rewrote it as it was quite buggy when used with selected text (that AppleScript doesn’t cut a string correctly if it contains umlauts never came to my mind …).

There are some options:

  • useMainWindow: controls if a record opens in a think or a document window.
  • usePageNumber: controls if the current page of a PDF is used in the Reference URL. If false other page related options are ignored.
  • showPageNumber: controls if the page number is added to the filename
  • showPageNumberWithoutSel: only add page number if text is selected
  • deleteStorageFile: during export DEVONthink creates a DEVONtech_storage file in the export folder. This option deletes it. Doesn’t make much sense if you use the script often. Better hide this file by running the following script once

Export a record via menu or script first, this file is not created if you drag a record to a folder.

-- Hide "DEVONtech_storage" file. Don't wonder, the file is not immediately hidden.

property destinationPath : (POSIX path of (path to desktop)) as string

do shell script "chflags hidden" & space & quoted form of (destinationPath & "DEVONtech_storage") as string

The script can’t create bookmarks for global smart groups and smart rules.

All other records can be linked:

  • record
  • group
  • tag
  • database smart group
  • database inbox
  • global inbox
  • trash

It can be run in a document window or a think window, if nothing is selected it uses the selection of the navigation sidebar.

Bookmarks don’t look pretty on the desktop but there’s a nice tool to change this:

If the path to this tool is set in option setFileIconPath

(e.g. (POSIX path of (path to home folder)) & ".SetFileIcon" as string))

then all bookmarks use DEVONthink icons :sunglasses:

Here’s the script

-- Create bookmark or alias on desktop

property useChooseFromList : true
property defaultChoice : "Bookmark" -- Bookmark / Alias
property useMainWindow : false
property useSelectedText : true -- if false no page number is used
property usePageNumber : true
property showPageNumber : true
property showPageNumberWithoutSel : false
property thePageFormat : ", S. "
property deleteStorageFile : false
property destinationPath : (POSIX path of (path to desktop)) as string
property setFileIconPath : "" -- don't change unless you use the free setFileIcon tool (http://www.hamsoftengineering.com/codeSharing/SetFileIcon/SetFileIcon.html)


tell application id "DNtp"
	try
		set windowClass to class of window 1
		if {viewer window, search window} contains windowClass then
			set currentRecord_s to selection of window 1
		else if windowClass = document window then
			set currentRecord_s to content record of window 1 as list
		end if
		
		set recordCount to (count currentRecord_s)
		if recordCount = 0 then set currentRecord_s to root of window 1 as list
		if recordCount > 1 then
			set useSelectedText to false
			set usePageNumber to false
		end if
		
		if useChooseFromList = false then
			set linkType to defaultChoice
		else
			activate
			set theChoice to (choose from list {"Bookmark", "Alias"} with title "Desktop" with prompt "" default items {defaultChoice})
			if theChoice = false then return
			set linkType to item 1 of theChoice
		end if
		
		repeat with theRecord in currentRecord_s
			
			set theRecordName to name of theRecord
			set theRecordPath to path of theRecord
			if theRecordPath ≠ "" then
				set theFilename to filename of theRecord
				set revFileName to (reverse of characters in theFilename as string)
				set theSuffix to reverse of characters 1 thru ((offset of "." in revFileName) - 1) in revFileName as string
				if theRecordName ends with theSuffix then set theRecordName to characters 1 thru -((count theSuffix) + 2) in theRecordName as string
			else
				set theSuffix to ""
			end if
			set theRefURL to reference URL of theRecord
			if useMainWindow = true then set theRefURL to theRefURL & "?reveal=1" as string
			set theType to type of theRecord as string
			
			set theName to theRecordName
			set foundText to false
			
			if useSelectedText = true then
				set selectedText to selected text of window 1
				try
					set selectedText to selectedText as string
					set theName to selectedText
					set foundText to true
				end try
			end if
			
			set thePage to ""
			
			if usePageNumber = true then
				if theType = "PDF document" then
					set currentPage to current page of window 1
					if currentPage ≠ -1 then
						set theRefURL to theRefURL & "?page=" & currentPage as string
						if showPageNumber = true then
							if foundText = true then
								set thePage to (thePageFormat & (currentPage + 1)) as string
							else
								if showPageNumberWithoutSel = true then
									set thePage to (thePageFormat & (currentPage + 1)) as string
								end if
							end if
						end if
					end if
				end if
			end if
			
			if linkType = "Bookmark" then
				set theBookmark to create record with {name:theName, URL:theRefURL, type:bookmark} in incoming group
				set theBookmarkPath to export record theBookmark to destinationPath
				delete record theBookmark
				if setFileIconPath ≠ "" then my setIcon(theType, kind of theRecord, theBookmarkPath, setFileIconPath)
				
				tell application "Finder"
					try
						set theFile to file (POSIX file theBookmarkPath as alias)
						set extension hidden of theFile to true
						if theName ≠ theRecordName or thePage ≠ "" then
							set theSuffix to "inetloc"
							set trimmedName to my trimName(theName, thePage, theSuffix)
							set name of theFile to (trimmedName & thePage & "." & theSuffix) as string
						end if
						if deleteStorageFile = true then delete file (POSIX file (destinationPath & "DEVONtech_storage") as alias)
					on error
						if deleteStorageFile = true then delete file (POSIX file (destinationPath & "DEVONtech_storage") as alias)
					end try
				end tell
				
			else if linkType = "Alias" then
				tell application "Finder"
					try
						exists (POSIX file ((destinationPath & theName) as string) as alias) as alias
						activate
						display alert "Hoppla!" buttons {"Beenden", "Ok"} default button 2 message "Name bereits vergeben." as critical
						return
					end try
					set theAlias to make alias file to (POSIX file theRecordPath) at folder (POSIX file destinationPath as alias)
					set extension hidden of theAlias to true
					if theName ≠ theRecordName or thePage ≠ "" then
						set trimmedName to my trimName(theName, thePage, theSuffix)
						set name of theAlias to (trimmedName & thePage) as string
					end if
				end tell
			end if
			
		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

on trimName(theName, thePage, theSuffix)
	if theName begins with "." then set theName to characters 2 thru -1 in theName as string
	if theName begins with space then set theName to characters 2 thru -1 in theName as string
	
	set pageSuffix to (thePage & "." & theSuffix) as string
	set totalLength to (do shell script "export LANG=\"en_US.UTF-8\" && echo " & quoted form of ((theName & pageSuffix) as string) & " | wc -c") as number
	
	if totalLength > 255 then
		set pageSuffixLength to (do shell script "export LANG=\"en_US.UTF-8\" && echo " & quoted form of pageSuffix & " | wc -c") as number
		set maxLength to 255 - pageSuffixLength
		set trimmedName to (do shell script "export LANG=\"en_US.UTF-8\" && echo " & quoted form of theName & " | tr -d " & quoted form of "\\n" & " | cut -c-1-" & maxLength & " -  | tr -d " & quoted form of "\\n")
	else
		set trimmedName to theName
	end if
end trimName

on setIcon(theType, theKind, theBookmarkPath, setFileIconPath)
	if theType = "group" then
		if theKind = "Tag" then
			set iconPath to "/Applications/DEVONthink 3.app/Contents/Resources/Tag-Group.icns"
		else
			set iconPath to "/Applications/DEVONthink 3.app/Contents/Resources/Group.icns"
		end if
	else if theType = "smart group" then
		set iconPath to "/Applications/DEVONthink 3.app/Contents/Resources/Smart-Group.icns"
	else
		set iconPath to "/Applications/DEVONthink 3.app/Contents/Resources/dtRecord.icns"
	end if
	do shell script quoted form of setFileIconPath & " -image " & quoted form of iconPath & " -file " & quoted form of theBookmarkPath
end setIcon
2 Likes

Thanks - that works to create an alias

Any idea why I cannot then move the alias to be a Finder favorite?

You can’t add aliases to the Finder’s sidebar.

That would explain it :slight_smile:

Is there any way to add DT3 groups (other than the Inbox) to the Finder sidebar?

No. They don’t exist in the filesystem so there’s nothing to alias to.

1 Like

I’ve updated the script following an advice from @BLUEFROG in another thread. It now only trims the name if it’s necessary.

There was a problem with the name trimming I didn’t notice while testing. Took some time to understand why it works in Keyboard Maestro and Alfred but not in DEVONthink, Script Editor or BetterTouchTool. Adding export LANG="en_US.UTF-8" in the handler fixed this.

IMHO, the programming lines in this forum are going to be one of the most important assets for many DT users. It is because all scripts here is about DT and how to interface with DT. To my limited knowledge, there are few forums of info mgt app that has the combination of a large number of active users, users with different professions and usage cases, and users with technical resources that are dedicated to AppleScript.

It is fascinating to see the evolution in the nature of scripts from the precise and effective gap-filling solutions contributed by first-gen members since the early 2000s to the scripts we see today.

Make no mistake that I am suggesting longer and more complicated scripts are better. In fact, I think it’s just the natural consequence of (1) users can already achieve many tasks by utilising the power and flexible build-in features of DT3, (2) we are all standing on the shoulder of previous contributors in DT related scripts, and (3) the numerous help and fixes for scripting questions coming from @bluefrog and @cgrunenberg. I wonder how fun it will be if only they are allowed(?) to post their pet-scripts! :smile:

Actually most of my scripts are/were shipped or posted here. For my own needs I use fewer and fewer scripts - the next release makes one obsolete and version 3 just like version 2 made many former scripts obsolete too.

Now the most important scripts are the embedded ones of smart rules or reminders, e.g. to download images from ESO or NASA feeds or the astronomy picture of the day.

1 Like

That’s the idea!

This version recognizes groups and PDF records reliably when used from DEVONthink’s script menu by using raw syntax e.g. «constant ****pdf ».

It also supports more icons (in case you’ve installed setFileIcon and set the path).

These are resulting links on desktop (of course the actual record names are used …)

2020-07-03_01-51-47

-- Create bookmark or alias on desktop

property useChooseFromList : true
property defaultChoice : "Bookmark" -- "Bookmark" or "Alias"
property useMainWindow : false
property usePageNumber : true
property showPageNumber : true
property showPageNumberWithoutSel : false
property thePageFormat : ", S. "
property deleteStorageFile : false
property destinationPath : (POSIX path of (path to desktop)) as string
property setFileIconPath : "" -- don't change unless you use the free setFileIcon tool (http://www.hamsoftengineering.com/codeSharing/SetFileIcon/SetFileIcon.html)
property resourcesPath : (POSIX path of (path to application id "DNtp") as text) & "/Contents/Resources/" as string

tell application id "DNtp"
	try
		set windowClass to class of window 1
		if {viewer window, search window} contains windowClass then
			set currentRecord_s to selection of window 1
		else if windowClass = document window then
			set currentRecord_s to content record of window 1 as list
		end if
		
		set useSelectedText to true
		set recordCount to (count currentRecord_s)
		if recordCount = 0 then set currentRecord_s to root of window 1 as list
		if recordCount > 1 then
			set useSelectedText to false
			set usePageNumber to false
		end if
		
		if useChooseFromList = false then
			set linkType to defaultChoice
		else
			activate
			set theChoice to (choose from list {"Bookmark", "Alias"} with title "Desktop" with prompt "" default items {defaultChoice})
			if theChoice = false then return
			set linkType to item 1 of theChoice
		end if
		
		repeat with thisRecord in currentRecord_s
			set theRecordName to name of thisRecord
			set theRecordPath to path of thisRecord
			if theRecordPath ≠ "" then
				set theFilename to filename of thisRecord
				set revFileName to (reverse of characters in theFilename as string)
				set theSuffix to reverse of characters 1 thru ((offset of "." in revFileName) - 1) in revFileName as string
				if theRecordName ends with theSuffix then set theRecordName to characters 1 thru -((count theSuffix) + 2) in theRecordName as string
			else
				set theSuffix to ""
			end if
			set theRefURL to reference URL of thisRecord
			if useMainWindow = true then set theRefURL to theRefURL & "?reveal=1" as string
			set theType to type of thisRecord as string
			
			set theName to theRecordName
			set foundText to false
			if useSelectedText = true then
				try
					set selectedText to selected text of window 1 & "" as string
					set theName to selectedText
					set foundText to true
				end try
			end if
			
			set thePage to ""
			if usePageNumber = true then
				if theType = "«constant ****pdf »" or theType = "PDF document" then
					set currentPage to current page of window 1
					if currentPage ≠ -1 then
						set theRefURL to theRefURL & "?page=" & currentPage as string
						if showPageNumber = true then
							if foundText = true then
								set thePage to (thePageFormat & (currentPage + 1)) as string
							else
								if showPageNumberWithoutSel = true then
									set thePage to (thePageFormat & (currentPage + 1)) as string
								end if
							end if
						end if
					end if
				end if
			end if
			
			if linkType = "Bookmark" then
				set theBookmark to create record with {name:theName, URL:theRefURL, type:bookmark} in incoming group
				set theBookmarkPath to export record theBookmark to destinationPath
				delete record theBookmark
				if setFileIconPath ≠ "" then my setIcon(thisRecord, theType, kind of thisRecord, theBookmarkPath, setFileIconPath)
				tell application "Finder"
					try
						set theFile to file (POSIX file theBookmarkPath as alias)
						set extension hidden of theFile to true
						if theName ≠ theRecordName or thePage ≠ "" then
							set theSuffix to "inetloc"
							set trimmedName to my trimName(theName, thePage, theSuffix)
							set name of theFile to (trimmedName & thePage & "." & theSuffix) as string
						end if
						if deleteStorageFile = true then delete file (POSIX file (destinationPath & "DEVONtech_storage") as alias)
					on error
						if deleteStorageFile = true then delete file (POSIX file (destinationPath & "DEVONtech_storage") as alias)
					end try
				end tell
				
			else if linkType = "Alias" then
				tell application "Finder"
					try
						exists (POSIX file ((destinationPath & theName) as string) as alias) as alias
						activate
						display alert "Hoppla!" buttons {"Beenden", "Ok"} default button 2 message "Name bereits vergeben." as critical
						return
					end try
					set theAlias to make alias file to (POSIX file theRecordPath) at folder (POSIX file destinationPath as alias)
					set extension hidden of theAlias to true
					if theName ≠ theRecordName or thePage ≠ "" then
						set trimmedName to my trimName(theName, thePage, theSuffix)
						set name of theAlias to (trimmedName & thePage) as string
					end if
				end tell
			end if
		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

on trimName(theName, thePage, theSuffix)
	if theName begins with "." then set theName to characters 2 thru -1 in theName as string
	if theName begins with space then set theName to characters 2 thru -1 in theName as string
	set pageSuffix to (thePage & "." & theSuffix) as string
	set totalLength to (do shell script "export LANG=\"en_US.UTF-8\" && echo " & quoted form of ((theName & pageSuffix) as string) & " | wc -c") as number
	if totalLength > 255 then
		set pageSuffixLength to (do shell script "export LANG=\"en_US.UTF-8\" && echo " & quoted form of pageSuffix & " | wc -c") as number
		set maxLength to 255 - pageSuffixLength
		set trimmedName to (do shell script "export LANG=\"en_US.UTF-8\" && echo " & quoted form of theName & " | tr -d " & quoted form of "\\n" & " | cut -c-1-" & maxLength & " -  | tr -d " & quoted form of "\\n")
	else
		set trimmedName to theName
	end if
end trimName

on setIcon(theRecord, theType, theKind, theBookmarkPath, setFileIconPath)
	tell application id "DNtp"
		try
			if theType = "«constant ****DTgr»" or theType = "group" then
				if theKind = "Tag" then
					set iconPath to resourcesPath & "Tag.icns" as string
				else if location of theRecord = "/" and name of theRecord = "Tags" then
					set iconPath to resourcesPath & "Tag-Group.icns" as string
				else if reference URL of theRecord = reference URL of incoming group of database of theRecord then
					set iconPath to resourcesPath & "Inbox.icns" as string
				else
					set iconPath to resourcesPath & "Group.icns" as string
				end if
			else if theType = "«constant ****DTsg»" or theType = "smart group" then
				set iconPath to resourcesPath & "Smart-Group.icns" as string
				set searchPredicates to search predicates of theRecord
				repeat with thisWord in (words of searchPredicates)
					if thisWord is in {"additionDate", "creationDate", "dueDate", "modificationDate", "openingDate"} then
						set iconPath to resourcesPath & "Smart-Date.icns" as string
						exit repeat
					end if
				end repeat
			else if theType = "«constant ****feed»" or theType = "feed" then
				set iconPath to resourcesPath & "RSS.icns" as string
				if URL of theRecord starts with "feed://twitter.com/" then set iconPath to resourcesPath & "Twitter.icns" as string
			else
				set iconPath to resourcesPath & "dtRecord.icns" as string
			end if
		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
	do shell script quoted form of setFileIconPath & " -image " & quoted form of iconPath & " -file " & quoted form of theBookmarkPath
end setIcon

This version can be used with indexed folders

-- Create bookmark or alias on desktop

property useChooseFromList : true
property defaultChoice : "Bookmark" -- "Bookmark" or "Alias"
property useMainWindow : false
property usePageNumber : true
property showPageNumber : true
property showPageNumberWithoutSel : false
property thePageFormat : ", S. "
property deleteStorageFile : false
property destinationPath : (POSIX path of (path to desktop)) as string
property setFileIconPath : "" -- don't change unless you use the free setFileIcon tool (http://www.hamsoftengineering.com/codeSharing/SetFileIcon/SetFileIcon.html)
property resourcesPath : (POSIX path of (path to application id "DNtp") as text) & "/Contents/Resources/" as string

tell application id "DNtp"
	try
		set windowClass to class of window 1
		if {viewer window, search window} contains windowClass then
			set currentRecord_s to selection of window 1
		else if windowClass = document window then
			set currentRecord_s to content record of window 1 as list
		end if
		
		set useSelectedText to true
		set recordCount to (count currentRecord_s)
		if recordCount = 0 then set currentRecord_s to root of window 1 as list
		if recordCount > 1 then
			set useSelectedText to false
			set usePageNumber to false
		end if
		
		if useChooseFromList = false then
			set linkType to defaultChoice
		else
			activate
			set theChoice to (choose from list {"Bookmark", "Alias"} with title "Desktop" with prompt "" default items {defaultChoice})
			if theChoice = false then return
			set linkType to item 1 of theChoice
		end if
		
		repeat with thisRecord in currentRecord_s
			set theRecordName to name of thisRecord
			set theRecordPath to path of thisRecord
			if theRecordPath ≠ "" then
				set theFilename to filename of thisRecord
				if theFilename contains "." then
					set revFileName to (reverse of characters in theFilename as string)
					set theSuffix to reverse of characters 1 thru ((offset of "." in revFileName) - 1) in revFileName as string
					if theRecordName ends with theSuffix then set theRecordName to characters 1 thru -((count theSuffix) + 2) in theRecordName as string
				else
					set theSuffix to ""
				end if
			else
				set theSuffix to ""
			end if
			set theRefURL to reference URL of thisRecord
			if useMainWindow = true then set theRefURL to theRefURL & "?reveal=1" as string
			set theType to type of thisRecord as string
			
			set theName to theRecordName
			set foundText to false
			if useSelectedText = true then
				try
					set selectedText to selected text of window 1 & "" as string
					set theName to selectedText
					set foundText to true
				end try
			end if
			
			set thePage to ""
			if usePageNumber = true then
				if theType = "«constant ****pdf »" or theType = "PDF document" then
					set currentPage to current page of window 1
					if currentPage ≠ -1 then
						set theRefURL to theRefURL & "?page=" & currentPage as string
						if showPageNumber = true then
							if foundText = true then
								set thePage to (thePageFormat & (currentPage + 1)) as string
							else
								if showPageNumberWithoutSel = true then
									set thePage to (thePageFormat & (currentPage + 1)) as string
								end if
							end if
						end if
					end if
				end if
			end if
			
			if linkType = "Bookmark" then
				set theBookmark to create record with {name:theName, URL:theRefURL, type:bookmark} in incoming group
				set theBookmarkPath to export record theBookmark to destinationPath
				delete record theBookmark
				if setFileIconPath ≠ "" then my setIcon(thisRecord, theType, kind of thisRecord, theBookmarkPath, setFileIconPath)
				tell application "Finder"
					try
						set theFile to file (POSIX file theBookmarkPath as alias)
						set extension hidden of theFile to true
						if theName ≠ theRecordName or thePage ≠ "" then
							set theSuffix to "inetloc"
							set trimmedName to my trimName(theName, thePage, theSuffix)
							set name of theFile to (trimmedName & thePage & "." & theSuffix) as string
						end if
						if deleteStorageFile = true then delete file (POSIX file (destinationPath & "DEVONtech_storage") as alias)
					on error
						if deleteStorageFile = true then delete file (POSIX file (destinationPath & "DEVONtech_storage") as alias)
					end try
				end tell
				
			else if linkType = "Alias" then
				tell application "Finder"
					try
						exists (POSIX file ((destinationPath & theName) as string) as alias) as alias
						activate
						display alert "Hoppla!" buttons {"Beenden", "Ok"} default button 2 message "Name bereits vergeben." as critical
						return
					end try
					set theAlias to make alias file to (POSIX file theRecordPath) at folder (POSIX file destinationPath as alias)
					set extension hidden of theAlias to true
					if theName ≠ theRecordName or thePage ≠ "" then
						set trimmedName to my trimName(theName, thePage, theSuffix)
						set name of theAlias to (trimmedName & thePage) as string
					end if
				end tell
			end if
		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

on trimName(theName, thePage, theSuffix)
	if theName begins with "." then set theName to characters 2 thru -1 in theName as string
	if theName begins with space then set theName to characters 2 thru -1 in theName as string
	set pageSuffix to (thePage & "." & theSuffix) as string
	set totalLength to (do shell script "export LANG=\"en_US.UTF-8\" && echo " & quoted form of ((theName & pageSuffix) as string) & " | wc -c") as number
	if totalLength > 255 then
		set pageSuffixLength to (do shell script "export LANG=\"en_US.UTF-8\" && echo " & quoted form of pageSuffix & " | wc -c") as number
		set maxLength to 255 - pageSuffixLength
		set trimmedName to (do shell script "export LANG=\"en_US.UTF-8\" && echo " & quoted form of theName & " | tr -d " & quoted form of "\\n" & " | cut -c-1-" & maxLength & " -  | tr -d " & quoted form of "\\n")
	else
		set trimmedName to theName
	end if
end trimName

on setIcon(theRecord, theType, theKind, theBookmarkPath, setFileIconPath)
	tell application id "DNtp"
		try
			if theType = "«constant ****DTgr»" or theType = "group" then
				if theKind = "Tag" then
					set iconPath to resourcesPath & "Tag.icns" as string
				else if location of theRecord = "/" and name of theRecord = "Tags" then
					set iconPath to resourcesPath & "Tag-Group.icns" as string
				else if reference URL of theRecord = reference URL of incoming group of database of theRecord then
					set iconPath to resourcesPath & "Inbox.icns" as string
				else
					set iconPath to resourcesPath & "Group.icns" as string
				end if
			else if theType = "«constant ****DTsg»" or theType = "smart group" then
				set iconPath to resourcesPath & "Smart-Group.icns" as string
				set searchPredicates to search predicates of theRecord
				repeat with thisWord in (words of searchPredicates)
					if thisWord is in {"additionDate", "creationDate", "dueDate", "modificationDate", "openingDate"} then
						set iconPath to resourcesPath & "Smart-Date.icns" as string
						exit repeat
					end if
				end repeat
			else if theType = "«constant ****feed»" or theType = "feed" then
				set iconPath to resourcesPath & "RSS.icns" as string
				if URL of theRecord starts with "feed://twitter.com/" then set iconPath to resourcesPath & "Twitter.icns" as string
			else
				set iconPath to resourcesPath & "dtRecord.icns" as string
			end if
		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
	do shell script quoted form of setFileIconPath & " -image " & quoted form of iconPath & " -file " & quoted form of theBookmarkPath
end setIcon

In case you’re trying to run the script I posted in this thread you’ll find that it doesn’t work in DEVONthink 3.6.

That’s due to DEVONthink’s new handling of “invalide arguments”. After the release of DEVONthink 3 I decided to continue to use “search window” in scripts so that DEVONthink 2 users could use them in, well, search windows. With version 3.6 that’s not possible anymore.

If you want to use the script you’ll have to replace this voluminous block …

set windowClass to class of window 1
if {viewer window, search window} contains windowClass then
	set currentRecord_s to selection of window 1
else if windowClass = document window then
	set currentRecord_s to content record of window 1 as list
end if

… with this neat line …

set currentRecord_s to selected records

… which does what the six lines have done. Wow, that’s great! :smiley: