Bookends and Devonthink

Users asking other users for AppleScripts that work with Bookends.
Post Reply
NilsMS
Posts: 53
Joined: Mon Sep 16, 2013 10:13 am

Bookends and Devonthink

Post by NilsMS »

I have adapted the script for Bibdesk and Devonthink
(http://www.organognosi.com/how-to-conne ... n-bibdesk/)
mentioned here: viewtopic.php?f=2&t=3385&hilit=devonthi ... =15#p15335
to work with Bookends and Devonthink. First, the right reference in BE and the pdf in DT have to be selected. Then, the script has to be invoked (I do that with Alfred); it pastes the BE-URL into the URL-field of Devonthink and copies the internal reference of Devonthink to the Clipboard, then returns to BE. Unfortunately, I did not find a way to paste it automatically in a field of my choice, so this has to be done by hand. I would very much appreciate other solutions!

Cheers,

Nils

Code: Select all

tell application "Bookends"
	try
		set theID to «event ToySRUID» "Selection"
	end try
end tell

tell application id "com.devon-technologies.thinkpro2"
	try
		set theRecord to the content record of think window 1
		set the URL of theRecord to ("bookends://sonnysoftware.com/" & theID) as text
		set theVerweis to reference URL of theRecord
		set the clipboard to theVerweis
	end try
end tell

tell application "Bookends"
	activate
end tell

NilsMS
Posts: 53
Joined: Mon Sep 16, 2013 10:13 am

Bookends and Devonthink Update

Post by NilsMS »

The problem mentioned above was solved in one of the last updates, so I post an updated version here (the devonthink link is pasted in user-field 20).

Code: Select all

tell application "Bookends"
	try
		set theID to «event ToySRUID» "Selection"
		if theID is {} then error "Nothing selected in Bookends!"
	end try
end tell

tell application id "com.devon-technologies.thinkpro2"
	try
		set theVerweis to ""
		set theRecord to the content record of think window 1
		if theRecord is {} then error "Nothing selected in DevonThink Pro!"
		set the URL of theRecord to ("bookends://sonnysoftware.com/" & theID) as text
		set theVerweis to reference URL of theRecord
	end try
end tell

tell application "Bookends"
	activate
	try
		«event ToySSFLD» theID given «class FLDN»:"user20", string:theVerweis
	end try
end tell

Nhaps
Posts: 214
Joined: Mon Sep 26, 2011 10:05 pm

Re: Bookends and Devonthink

Post by Nhaps »

Much appreciated, thank you. If I may improve on the workflow I would ask whether it is possible to automate the process with another script; that is, the script would include DTP links into User20 field only for BE references that already have attachments. This new script for multiple references would be a nice addition to the already sucessful one for single reference.

Cassady
Posts: 167
Joined: Thu Aug 22, 2013 3:48 pm
Location: Sqornshellous

Re: Bookends and Devonthink Update

Post by Cassady »

NilsMS wrote:The problem mentioned above was solved in one of the last updates, so I post an updated version here (the devonthink link is pasted in user-field 20).
Hi NilsMS!

Many thanks for this script – I'm sure it's going to prove really useful, but I'm unfortunately stuck on setting it up in Alfred.
Could you or anyone familiar with how to run Script actions in Alfred, please advise?

I have assigned a keyword – with the [Outputs] set to Run Script >> would I then select the /bin/bash "language", leave the default settings as if, and replace the LAST "query" in

Code: Select all

query="{query)"
with the copied code-text?
I've tried this, and nothing fired.

Alternatively, I selected the "Run NSAppleScript" under the [Actions] menu – and at the "-- your script here" , in

Code: Select all

on alfred_script(q)
–– your script here
end alfred_script|
I again pasted the code-text, without anything happening.

If anyone could point me in the right direction, that would be great – failing which, I'll go see if anyone over at the Alfred forums can help!

Thanks again!

Cassady
Posts: 167
Joined: Thu Aug 22, 2013 3:48 pm
Location: Sqornshellous

Re: Bookends and Devonthink

Post by Cassady »

Live and learn! :D

Figured it out – needed to make minor changes to the script formatting, that I figured out by comparing it to a different NSApplescript workflow, that I had imported off the Alfred forums!

A couple of questions:

1.) Inside DTPO – the URL is very conveniently placed under the toolbar in the PDF annotation view – in a similar location to where DTPO's internal 'wiki-links' URLs, between the source PDF and the Annotation note are placed, should you create one.
In the event that one already exists, would the script override that initial URL, and replace it with the BEs one?

2.) Over in BE, in the User20 field – the URL is placed as plaintext, (i.e.) not clickable? Am I missing something, a view or something that displays the URL as a clickable one, or is it simply intended as a reference point, to invoke elsewhere, should it be needed?

Many thanks again!

Nhaps
Posts: 214
Joined: Mon Sep 26, 2011 10:05 pm

Re: Bookends and Devonthink

Post by Nhaps »

1) Yes, the URL provides a nice way in DT to go back to BE. I would assume that the BE URL is updated every time the script is invoked/deployed.
2) Yep, you are missing something. DT link is not supposed to be clickable in the main view/library window but in the Summary and All Fields views
Let us know how you're using Alfred, and if you have something to say to my post above, about whether a global/multiple script makes sense.

NilsMS
Posts: 53
Joined: Mon Sep 16, 2013 10:13 am

Re: Bookends and Devonthink

Post by NilsMS »

At least with my setup, Alfred works much, much simpler: I have saved the script as application and renamed it to be as unique as possible (it does not really matter where it is saved, Alfred will find it). I then invoke Alfred by typing ALT-Tabulator, and usually already the first two typed letters return my script, so I have just to press return to start it.

ad 1) Yes, it is indeed overwritten, which might not be convenient in cases where the pdf is already linked to another document within DT (e. g. RTF-notes referring to the pdf). In those cases, I take care that the link from BE leads to the latter document. There, I have created a link to the pdf (from where I can get back to the RTF-document and from there to the BE-reference, if need be).

@Nhaps: I am not sure if I have grasped your suggestion. If you meant to add links to more than one document at once, I would not know how to do this. My Applescript-knowledge is rather limited, perhaps Korm at the DT-forum would be the right to ask.

Cheers,

Nils

Cassady
Posts: 167
Joined: Thu Aug 22, 2013 3:48 pm
Location: Sqornshellous

Re: Bookends and Devonthink

Post by Cassady »

Nhaps wrote: 2) Yep, you are missing something. DT link is not supposed to be clickable in the main view/library window but in the Summary and All Fields views
Let us know how you're using Alfred, and if you have something to say to my post above, about whether a global/multiple script makes sense.
Thanks. I've figured it out >> the "problem" was my not having selected the User20 'field' as being one to display in either the "Summary" or "All Fields" list – needed to make the adjustment inside the BE Preferences settings.

This works a TREAT!
My only concern, is the possible overwrite of a already existing URL linking the DTPO file to another annotation note. Given how I use the latter, this would be problematic were I to break that link.

I guess the simplest way around it would be to simply check before invoking the script! Of course, if a later annotation note is created – it would presumably also overwrite the BE12 link!
That all being said – the conversations over at DTPO appear to suggest that the new version will improve metadata capacity – and how virtual links are dealt with. Hopefully that update will provide the leeway to get around the challenges listed above!


RE your last point: Are you querying the possibility of selecting several references at once in DTPO, and have the URL dropped into several references over in BE at the same time? Or am I misunderstanding you?

Nhaps
Posts: 214
Joined: Mon Sep 26, 2011 10:05 pm

Re: Bookends and Devonthink

Post by Nhaps »

Nils, yes I meant adding links to multiple docs at once. I will ask korm/DT-forum, thanks.

Nhaps
Posts: 214
Joined: Mon Sep 26, 2011 10:05 pm

Re: Bookends and Devonthink

Post by Nhaps »

@Cassady, you're right, one must choose between BE links or DT annotations to take the URL spot. As for "Are you querying the possibility of selecting several references at once in DTPO, and have the URL dropped into several references over in BE at the same time? Or am I misunderstanding you?" I would say...

Yes, I am looking for a way to make the script match more than one pair of reference between DT and BE based on the same filename. That is, the script would deploy if the DT filename (for example "authoryear - title") would match certain fields in BE. It would then insert the DT URL into BE user 20. This would be wonderful, a bi-directional link between all files in DT and BE. Script experts, let's find a way to do this!

Post Reply