Thanks to everyone’s help, and a lot of tinkering, I feel like I’m getting pretty close, but I’m still stuck on a few small things. In short, I’d like to create two versions of the script: (1) that opens the file or group in DEVONthink’s current viewer window (selecting/highlighting the file and previewing it, or in the case of groups, showing their contents), and (2) another that reveals the file or group, similar to how “reveal” works from the context menu of a search result.
Unfortunately, with both scripts, I keep getting hung up on two core things:
First, is it possible to get @ngan’s wonderful script to search all databases? I only have one big database, and two relatively small ones, but I’d love to be able to search all of them at once, similar to @korm’s great KM script. I tried just setting a variable for them, which works well when you just want to open the file. However, I can’t seem to get it to work when you want to reveal the file in your current viewer window
In any event, here’s a copy of the “reveal” script (the second one from above), which combines aspects of @ngan and @korm’s scripts. It will reveal files and groups appropriately, but doesn’t seem to search every database:
tell application "Finder"
set theSelection to selection as alias list
end tell
if theSelection ≠ {} then
set theFile to first item of theSelection
set theFilePath to POSIX path of (contents of theFile)
end if
tell application id "DNtp"
try
set theDatabases to databases
set theResults to {}
repeat with thisDatabase in theDatabases
set thisDatabasesResults to lookup records with path theFilePath in thisDatabase
set theResults to theResults & thisDatabasesResults
end repeat
if theResults = {} then
display notification "Pfad nicht in offenen Datenbanken enthalten!" with title "Lookup DEVONthink"
return
else
set root of viewer window 1 to (parent 1 of item 1 of theResults)
set selection of viewer window 1 to theResults
activate
end if
end try
end tell
As for the second problem, I could never get the “open” script from above to properly open the file or folder/group in the current DEVONthink viewer window. In other words, I couldn’t figure out how to adapt @ngan’s script so that instead of opening a new window, that it would do something similar in the viewer window that’s already open.
As always, thanks for any help you can lend. I’d be completely lost without everyone’s support. Also, apologies if I’ve butchered any DEVONthink verbiage above (or the English language, for that matter - Ha). Thanks again!