I was wondering if I could get the group’s help with this script again? By way of reminder, one of the scripts that I originally posted was intended to “reveal” files from Finder in a new DEVONthink window (first, find the file in DEVONthink; then, open a new window for its parent folder/group in DEVONthink; finally, select the file in the new DEVONthink window). However, I’ve never been able to figure out how to get this particular script to work with more than one file at a time.
In the script below, it seems clear to me that the problem lies in the way that I’ve set the window (when opening it and setting its selection). However, I’ve never understood how to deal with this issue in DEVONthink. Because I’ve set the window’s name, in order to make a selection, when there is more than one file, they all open in the same window. Does anyone know how to fix those last couple lines of code, so that each file opens in its own window and is selected appropriately (i.e., the lines beginning with “set theWindow…”)?
Thanks again for all of your help!! To make things easy for everyone, I’ve also uploaded the script here: Download Script.
tell application "Finder"
set theSelection to selection as alias list
end tell
if theSelection ≠ {} then
set my text item delimiters to tab
set theFilePaths to {}
repeat with i in theSelection
set end of theFilePaths to POSIX path of (contents of i)
end repeat
end if
if theFilePaths ≠ {} then
repeat with i in theFilePaths
tell application id "DNtp"
try
set theDatabases to databases
set theResults to {}
repeat with thisDatabase in theDatabases
set thisDatabasesResults to lookup records with path i in thisDatabase
set theResults to theResults & thisDatabasesResults
end repeat
if theResults is not {} then
set theResultsParent to (first parent of first item of theResults)
set theWindow to open window for record theResultsParent
set theWindow's selection to theResults
else
display alert "the file/group does not exist in the current DT database"
end if
end try
end tell
end repeat
end if