Is it possible to change the way that indexing is performed for a folder?
I have a folder that contains a Calibre library. The Calibre library indexes fine but each item (book) also has a side-car type file with useful meta data. The meta data are in XML format. What I would like to do is create something to read the XML data from the indexed file and populate the tags of the book in DT3.
This Smart Rule script should do it. Set the search predicates to kind = pdf (and tags ≠ * if you only want to set them once).
Don’t think there’s a trigger “during index”
-- Use calibre keywords as tags
property tagStart : "<dc:subject>"
property tagEnd : "</dc:subject>"
property tagStart_length : length of tagStart
on performSmartRule(theRecords)
tell application id "DNtp"
try
repeat with thisRecord in theRecords
set theText to plain text of (get record at (location of thisRecord) & "metadata.opf")
set theLines to paragraphs of theText
set theKeywords to {}
repeat with thisLine in theLines
set thisLine to thisLine as string
if thisLine contains tagStart then
set end of theKeywords to characters ((offset of tagStart in thisLine) + tagStart_length) thru ((offset of tagEnd in thisLine) - 1) in thisLine as string
end if
end repeat
set tags of thisRecord to (tags of thisRecord) & theKeywords
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