For some reason I cannot figure out why the following is failing when triggered by a smart rule (as external scpt) and runs successfully when triggered from scriptdebugger, on the items in the smart rule view.
It seems it cannot perform the “get custom meta data” properly when triggered from the smart rule.
Was running well in 4.0 and 4.1, broke at some point. breaks when running 4.2.2.
Any idea?
use AppleScript version "2.4" -- Yosemite (10.10) or later
-- when calling on selection / single file
on run
tell application id "DNtp"
setThumbnails((selection of think window 1) as list) of me
end tell
end run
-- when called by smart rule
on performSmartRule(theRecords)
tell application id "DNtp"
setThumbnails(theRecords) of me
end tell
end performSmartRule
-- generic wrapper to handle multiple snapshots
on setThumbnails(theRecords)
tell application id "DNtp"
show progress indicator "Setting thumbnails ..." steps (length of theRecords) + 1
repeat with theRecord in theRecords
setThumbnail(theRecord) of me
end repeat
hide progress indicator
end tell
end setThumbnails
-- record snapshotting
on setThumbnail(theRecord)
tell application id "DNtp"
set theType to (get custom meta data default value "" for "type" from theRecord) as string
if (theType is equal to "book") then
set color of theRecord to {26214, 14647, 455} -- book brown
else if (theType contains "article") then -- also for article series
set color of theRecord to {62450, 60392, 2523} -- article yellow
else if (theType is equal to "person") then
set color of theRecord to {50886, 12851, 65021} -- person pink
else if (theType is equal to "organization") then
set color of theRecord to {16190, 26985, 7709} -- org green
else if ("course,event,session,workshop" contains theType) then
set color of theRecord to {34437, 52686, 19789} -- event green
else if ("podcast episode,video" contains theType) then
set color of theRecord to {64847, 28802, 14389} -- video orange
end if
end tell
end setThumbnail
