How can I put PDFs in DTPO, and references in bookends?

The standard usage of Bookends + DTPO seems to be to index the Bookends Attachments folder in DEVONthink. But I really, really, really do not like indexing important information – if I replicate an indexed item and then later change the file name, the replicant just disappears. No bueno.

So I want to keep my PDFs in DEVONthink, drag them into Bookends, and have Bookends get all the nice metadata. It should link back to DEVONthink somehow for the original PDF.

Is that possible? I found this post from someone hoping to do the same thing, but there was no resolution on it.

Please do not tell me to index the attachments folder :slight_smile: I know how to do that, and I don’t want to.

Don’t really have an answer for you - but have you seen this topic?

[url]Linking Bookends entries and pdfs in Devonthink]

Here is the related discussion over on the Bookends forum:

It certainly worked at the time - but haven’t used it as much as I initially suspected, given that it served to overwrite any automatic links created when using the “Annotation” note feature in DTPO, the latter which I use extensively.

Regardless, the above might give you some ideas? Best of luck - shout if you find something! 8)

Thanks for that. I didn’t realize Bookends had any Applescript support – the dictionary is grayed out in Script Editor, but I found some basic scripting in the documentation.

I am VERY CLOSE to the workflow I want:

  • drag a PDF onto Bookends
  • fill in any metadata
  • rename the file according to my naming convention
  • move the attachment into DEVONthink
  • copy a link from DEVONthink into the user1 field of Bookends

So far I haven’t found a way to get (and clear out) the attachment reference… I suspect it’s not possible at the moment. But I’ve emailed Jon and hopefully he’ll show me the way.

Here’s a simple script that imports PDFs from Bookends to DEVONthink:

-- This script relies on a custom format called "Attachment Path"
-- which is defined simply as: m
-- handle errors
-- handle existing records in DEVONthink
-- delete original PDF?

-- change this to the Bookends user field you'd like to use for DEVONthink URLS:
set bookendsDTURLfield to "user1"

tell application "Bookends"
	set theIds to paragraphs of («event ToySRUID» "Selection")
	repeat with theId in theIds
		my importAttachment(theId)
	end repeat
end tell

on importAttachment(theId)
	tell application "Bookends"
		set thePath to «event ToySGUID» theId given string:"Attachment Path"
	end tell
	set thePath to do shell script "echo " & quoted form of thePath & "| /usr/bin/ruby -r cgi -e \"print CGI.unescape('file://', '')\""
	tell application id "DNtp"
		set theDocument to import thePath
		set URL of theDocument to "bookends://" & theId
		set theDTURL to reference URL of theDocument
	end tell
	tell application "Bookends"
		«event ToySSFLD» theId given «class FLDN»:my bookendsDTURLfield, string:theDTURL
	end tell
end importAttachment
1 Like

It’s not picking up the attachment path here.

This advocated form is tell application id “DNtp". Not wrong. Just a suggestion

You don’t need to string this together yourself. Just use reference URL of theDocument.

Did you create a format called “Attachment Path” as (briefly) mentioned in the opening comments?

Here’s the format I’m using. You can add it to ~/Library/Application Support/Bookends/Custom Formats

Thanks! Updated :slight_smile:

I was wondering if you can put Devonthink’s index (Files.noindex->pdf) as the default attachment folder for BE.

Would Devonthink consider the file as normal imported file?

I think at best it would consider it an orphaned file (although in which DB, I have no way of knowing).

This is precisely why I don’t want Bookends maintaining attachment references to the files. Once they go in DT, there’s no way of knowing where they’ll be on disk. That’s fine with me, I just don’t want Bookends saying the attachment has gone missing. That’s extra cognitive load for me.

btw the truly ideal scenario would be for DEVONthink to have some mechanism for locating missing files by way of file id on disk. That’s a feature provided by OS X that other apps (e.g. AudioFinder) use. You can move a file on disk, rename it, whatever you want, and AudioFinder can update its location no problem.

DEVONthink’s indexing is based on a hard-coded location. It could be way more useful if it took advantage of OS X’s file id mechanism.

You absolutely should not do this with any app.

I don’t understand what this script does. Doe it import the PDF to Devonthink’s database?
I see that the format gives the path to the file. But, if you import the PDF to Devonthink, won’t BE lose the attachment?

/a little experiment: I can import the pdf to Devonthink first; then attach it to BE reference. I can tell BE not to move it. It all works very fine. The problem would be; if I rename the file from BE, Devonthink misses it. Devonthink doesn’t tolerate any change within its database folder. BE has no problem if you move the attachment around so far as you don’t rename it. It can even find the attachment in the trash. BE is very interesting. If renaming can be avoided, it is possible to first put the PDF in Devonthink and then attach it to BE. it works fine. /

Yes it imports it. Then it sets the imported PDF’s URL to the bookends URL so you can one-click to the bookends reference. It also sets a custom field in the bookends so you can easily get to the DEVONthink PDF.

No bookends won’t lose the attachment, because importing copies the file instead of moving it.

But personally I want to delete the original file, because I don’t want bookends to have an attachment. I’ve talked about this before already.

I see.

Bookends now has a wonderful ios app. If you delete the original, you cannot use the bookends ios app for reading the pdf files.

Is the ios app of Devonthink good for reading pdf?

I think I will follow the traditional approach–keep my pdf files in Bookends. I don’t want Bookends to lose the attachment; nor the duplication of the files. If there is a way to point for both apps to use the same folder (resource), it would have been great. I have tried Sente and Bookends before. They shared a folder with no problem.

But, we cannot push the developers at Devonthink as they have already offered the index option.

I actually am now convinced that putting Devonthink’s index (Files.noindex->pdf) as the default attachment folder for BE is very possible. But, the process has to follow certain strict steps. It also requires that you have only one BE library. Multiple libraries would make it hard to point the default folder structure towards the Devonthink database/there is still a possibility to use symbolic links for multiple sub-folders of BE library; but I didn’t look at it/.

Here are the steps if sb wants to try out:

For already existing references:

  1. first, index the default folder of BE into Devonthink.
  2. in Devonthink, move into database
  3. change the default attachment folder in BE to Files.noindex->pdf

For new references

  1. First, make the Files.noindex->pdf as default attachment folder in BE
  2. Fill up your reference information–>Attache the PDF to BE reference without moving the PDF into the default folder (still keeping the PDF in your downloads folder, for instance). You have to say NO when BE asks you to move the attachment. This is the most important part of the steps. Otherwise, the Pdf will be an orphan in Devonthink.
  3. Rename the reference in BE (if you have to rename it: this is the time)
  4. Import the PDF to Devonthink.

Bookends has some magic. it will automatically find the PDF so far as Devonthink doesn’t rename it; and, that they are in the sub-folders of the default attachment folder.