Right click on a PDF in the Finder (or any other app that contains PDFs) to reveal the contextual menu.
Hover on “Open With…”
Click on DEVONthink.
Actual result: DEVONthink crashes hangs.
Expected result: Good question! With PDFs that are indexed or imported into DEVONthink, I would expect the app to simply open them. With other PDFs, I am not sure—neither do I have a strong opinion, as long as there is no crash.
If this is consistently reproducible…
Do a Spotlight search for Activity Monitor . When our application is stalled, go into Activity Monitor and select our application in the list of processes - it should show “(Not Responding)” and the name in red - and press Command-Option-S to run a sample on it. When the sample window opens, press the Save button and save it to your Desktop. The open a support ticket and attach the process sample.
Technically it’s identical to e.g. dropping onto the Dock or Finder icon and should import the files and a quick test on 26.1 was successful, therefore this might be related to the document and/or your setup.
Good question The PDFs in question appear as links to bibliographic records in BibDesk. The files themselves physically reside deep in the DEVONthink database. Opening them in DEVONthink allows me to quickly Cmd-R and reveal them in the database for further manipulation.
Essentially, I have been trying to import an already imported file. And since my default import location is the Inbox, not the database where the file is stored, I have been dislocating the file away from its proper location.
I’m not a BibDesk user, but if you are referring to DEVONthink’s item links, you wouldn’t use Open With. A URL scheme activates the application it belongs to.
How are you adding the references from DEVONthink to BibDesk?
Indeed, as far as I know BibDesk uses symlinks for links to files. The rationale is that symlinks do not break whenever the file is relocated to another path.
Bizarrely, the issue is no longer reproducible after putting my machine to sleep and waking it up…
How are you adding the references from DEVONthink to BibDesk?
I am actually doing it the other way around: I add files to BibDesk, which automatically archives them into the DEVONthink Inbox folder. Once there, they can be easily moved to my research database.
Some time ago I wrote a script that extracts the DEVONthink URI for those files and stores it in a custom devonthinkfield of the BibDesk record. This enables me to open imported PDFs directly from BibDesk on both platforms (macOS and iPadOS),
Had I not forgotten about my own script, I wouldn’t have wasted your time with this discussion. Sorry!
You’re welcome
The scripting support was rebuilt and updated to modern standards. And yes there have been some changes as well.
I build a small variant that’s returning the expected result…
tell application "BibDesk"
set filepaths to {}
set sel to (item 1 of (selection of document 1 as list))
if exists linked files of sel then set filepaths to (linked files of sel)
end tell
if filepaths is not {} then
tell application id "DNtp"
set theDatabase to current database
repeat with thePath in filepaths
set theMatches to (contents of theDatabase whose path is (POSIX path of thePath))
end repeat
end tell
end if
PS: There is an alternate method you could use: lookup records with, e.g., …
repeat with thePath in filepaths
set matchedDocs to (lookup records with path (POSIX path of thePath))
if matchedDocs is not {} then beep 2
end repeat
Your script makes sense for linking up previously imported PDFs. But going forward, wouldn’t it make sense to get the x-devonthink-item:// link and write it to the bibtex reference at the same time a PDF is imported to DEVONthink? I imagine that should be fairly easy to add to whatever automation you’ve set up?
The first variant is essentially the same as the original, if I’m not mistaken, and indeed it didn’t work. The second one did, however, so problem solved. Thank you, Jim!
@troejgaard The reason for initiating the workflow from BibDesk is that, incurably neurotic as always, I want my PDF filesystem names (not just their DT names) to match their titles. BibDesk takes care of that automatically before sending the PDF into the DT Inbox. On the contrary, renaming a PDF that has already been imported and indexed would corrupt the database.
I understand that you start in BibDesk. How exactly do you send the PDF from BibDesk to DT?
What I’m trying to say is that you could probably write the item link back to BibDesk immediately as part of the same process.
I haven’t scripted BibDesk before or used it much, so this is just symbolic code – but a rough sketch to illustrate:
tell application "BibDesk"
set thisPub to -- whatever makes sense
set thePath to POSIX path of (linked file of thisPub)
tell application id "DNtp"
set theRecord to (import thePath to incoming group)
set itemLink to reference URL of theRecord
end tell
tell thisPub to make new field with properties {name:"DEVONthink", value:itemLink}
end tell
Edit: Oh, I forgot that import results in a new file and thus breaks the symlink.
Unless I am misreading your sketch, I believe it represents more or less what I am doing. Here is my workflow step by step:
I drop a newly acquired PDF into BibDesk.
BibDesk creates a bibliography record for the PDF and populates the record with as much data as it can retrieve online.
I manually fill-in the remaining BibLaTeX fields.
I press Cmd-Shift-Kto:
let BibDesk give the PDF a standard filename (Title(Author).pdf); and
have the PDF “autofiled” in my directory of choice—in this case, the DEVONthink Inbox. This particular destination is key, as DEVONthink is designed to automatically import its contents into the database.
With the PDF now imported, I run my BibDesk script to have the x-devonthink-item` URIs of all attachments retrieved from the database and pasted into custom BibLaTeX fields.
Conceivably, I could probably also use a BibDesk hook to have Step 5 automatically executed as soon as the bib file is saved.
If you think there is a simpler way, I would be interested in hearing it!