Success! It’s working beautifully now!
Pete, this has been really helpful. Thanks again, also for pushing me a bit to find the solution on my own - that’s how one learns, right?
Here are the scripts, in case someone wants to use them.
Working smart rule script:
on performSmartRule(theRecords)
tell application id "DNtp"
try
repeat with theRecord in theRecords
set theText to plain text of theRecord as string
if theText ≠ "" then
set newText to script "ScriptLibraryReplacekeyword"'s replacekeyword(theText, "DT_Inbox")
if newText ≠ theText and newText ≠ "" and newText ≠ "missing value" then set plain text of theRecord to newText
end if
end repeat
on error error_message number error_number
if the error_number is not -128 then display alert "DEVONthink" message error_message as warning
end try
end tell
end performSmartRule
And this is the Script Library:
-- Script Library - replacekeyword
use AppleScript version "2.7"
use framework "Foundation"
use scripting additions
on replacekeyword(theText)
try
set ca to a reference to current application
set theString to ca's NSString's stringWithString:theText
set newString to theString's stringByReplacingOccurrencesOfString:("DT_Inbox") withString:("") options:(ca's NSRegularExpressionSearch) range:{location:0, |length|:length of theText}
set newText to newString as string
on error error_message number error_number
error number -128
end try
end replacekeyword