Setting up drag/drop or copy/paste from Devonthink

Nice. That works for me using v8.2.2 on 10.14.6.

Thank you both for this, @mwra and @sumnerg!

Iā€™m somewhat embarrassed to admit that Iā€™m working on an older Mac, and am therefore running 10.11.6 with Script Editor v. 2.8.1 ā€“ and using TB v. 8.1.1. Would it be possible to use some version of the scripts youā€™ve created for my set up?

Many thanks againā€¦

Iā€™d simply try it - it will either work or it wonā€™t!

1 Like

Ok, thanks. Just so Iā€™m doing everything properlyā€¦ Where would I save such a script? Thanks.

Great. Thanks!

Would it also be possible to get the result not directly pasted in Tinderbox but instead stored in the clipboard so one could paste it on the adequate position in Tinderbox manually?

Cheers

Open up Script Editor (in Applications > Utilities) and copy-paste the script into it. After selecting text in DT click the triangle button in Script Editor. If that works you can save the script from Script Editor, and open it up whenever you want to use it. If you think you will use it a lot then you can make it a menu pick by installing it in the Script menu in the menu bar.

If you will really use it a lot then you could also put it inside an Automator Quick Action (formerly called a Service) and attach a keyboard shortcut to it at System Preferences > Keyboard > Shortcuts > Services.

If you want the selected text from DT placed on the clipboard instead of in Text of the newly created note in Tinderbox then you can do something like this:

tell application "DEVONthink 3"
	tell item 1 of (get selection)
		set dtURL to reference URL
		set extURL to URL
	end tell
	set theSelectedText to selected text of think window 1
	set the clipboard to theSelectedText
end tell

set text item delimiters to " "
set theName to firstNWords(theSelectedText, 8)

tell application "Tinderbox 8"
	if not (exists front document) then make new document
	tell front document
		set myNote to make new note with properties {name:theName}
		tell myNote
			set value of attribute "ReferenceURL" to dtURL
			set value of attribute "URL" to extURL
			-- set value of attribute "Text" to theSelectedText
			set value of attribute "KeyAttributes" to "URL;ReferenceURL"
		end tell
	end tell
end tell

to firstNWords(someText, numWords)
	tell someText
		if its length is 0 then error "Select some text and run again."
		if length of its words < numWords then
			set theName to it
		else
			set theName to (its words 1 thru numWords as text)
		end if
	end tell
end firstNWords

Awesome. Thank you ever so much!

Could you kindly help me tweak the Script so that the name does not necessarily equals the length of the text but rather could be shortened to, say, 5 Words.

1 Like

As written, the script sets the name to the shorter of the entire selection or its first 8 words.

But you can change that to a different number of words.

Where you see ā€¦

set theName to firstNWords(theSelectedText, 8)

ā€¦ simply change the 8 to 5 (or whatever).

Thatā€™s the only change you need to make (donā€™t touch the 8 in ā€œTinderbox 8ā€)

1 Like