Hi
I was hoping you could help with a really simple Applescript. It finds an indexed file in the DevonThink database and figures out its corresponding remote file, then reveals that in the finder.
This works brilliantly when run from Script Debugger. The finder window opens and reveals the corresponding location of the currently selected DevonThink document.
However, if I run this in the DevonThink Toolbar, I get no errors on the error console, but no finder window opens. I’m wondering if it’s somehow a permissions issue? Normally I’d get a permissions request, though - asking permission for DT to control the other app:
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
property devonThinkPath : "/Volumes/DevonThink/OneDrive/"
property oneDrivePath : "/Volumes/Data2/OneDrive/Documents/"
tell application "DEVONthink 3"
set theSelection to the selection
set firstRecord to item 1 of theSelection
set thePath to path of firstRecord
end tell
set oneDrivePath to findAndReplaceInText(thePath, devonThinkPath, oneDrivePath)
set oneDrivePosixPath to POSIX file oneDrivePath
tell application "Finder" to reveal oneDrivePosixPath
on findAndReplaceInText(theText, theSearchString, theReplacementString)
set AppleScript's text item delimiters to theSearchString
set theTextItems to every text item of theText
set AppleScript's text item delimiters to theReplacementString
set theText to theTextItems as string
set AppleScript's text item delimiters to ""
return theText
end findAndReplaceInText