Sorry to be confusing. I’ve been using labels to consolidate files into a Smart Group. Thanks to @korm, I was able to then use the following trigger script to apply prefixes to labeled files that were in my groups (within my database):
on triggered(theRecord)
try
tell application id "com.devon-technologies.thinkpro2"
set theSelection to the every child of theRecord
-- set theSelection to selection
set labelCount to 0
-- display dialog "DEBUG at First Setting"
repeat with thisItem in theSelection
-- display dialog "DEBUG at Inside repeat"
-- first we get rid of existing prefixes
-- "1_" == I. Urgent, "2_" == II. High, "3_" == III. Moderate
set myName to the name of thisItem
if (the name of thisItem contains "1_") then
set myName to my trim_line(myName, "1_", 0)
else if (the name of thisItem contains "2_") then
set myName to my trim_line(myName, "2_", 0)
else if (the name of thisItem contains "3_") then
set myName to my trim_line(myName, "3_", 0)
end if
-- next we assign new prefixes, or none, based on the current label
-- label 1 == High, 2 == Medium, 3 == Low
if the label of thisItem is 1 then
set the name of thisItem to "1_" & myName
set labelCount to labelCount + 1
else if the label of thisItem is 2 then
set the name of thisItem to "2_" & myName
set labelCount to labelCount + 1
else if the label of thisItem is 3 then
set the name of thisItem to "3_" & myName
set labelCount to labelCount + 1
else
set the name of thisItem to myName
end if
end repeat
end tell
set Notified to my growlMe((labelCount as string) & " items were updated by Set Prefix Depending on Label")
end try
end triggered
-- Attribution: this "trim_line" sub-routine was provided by
-- http://www.macosxautomation.com/applescript/sbrt/sbrt-06.html
on trim_line(this_text, trim_chars, trim_indicator)
-- 0 = beginning, 1 = end, 2 = both
set x to the length of the trim_chars
-- TRIM BEGINNING
if the trim_indicator is in {0, 2} then
repeat while this_text begins with the trim_chars
try
set this_text to characters (x + 1) thru -1 of this_text as string
on error
-- the text contains nothing but the trim characters
return ""
end try
end repeat
end if
-- TRIM ENDING
if the trim_indicator is in {1, 2} then
repeat while this_text ends with the trim_chars
try
set this_text to characters 1 thru -(x + 1) of this_text as string
on error
-- the text contains nothing but the trim characters
return ""
end try
end repeat
end if
return this_text
end trim_line
-- for information on scripting Growl see
-- http://growl.info/documentation/applescript-support.php
on growlMe(myNotification)
tell application "System Events"
set isRunning to (count of (every process whose bundle identifier is "com.growl.growlhelperapp"))
end tell
if isRunning = 1 then
tell application id "com.growl.growlhelperapp"
set the allNotificationsList to {"Script Status", "Failure"}
set the enabledNotificationsList to {"Script Status", "Failure"}
register as application "DEVONthink Script" all notifications allNotificationsList default notifications enabledNotificationsList
notify with name "Script Status" title "DEVONthink Script Status" description myNotification application name "DEVONthink Script" with sticky
end tell
end if
end growlMe
This was @korm’s ingenious idea, and was borne out of this forum discussion:
[url]A better way to use MobileSync with GoodReader?]
I was actually hoping that the Smart Folder set up you helped create would allow me to use the same script for Tagged items. But there’s one drawback… Even if the set up you created places Tagged items in the appropriate smart folder (e.g., those files tagged as “Low” now appear in the Low smart folder) they are not labeled as low, so @korm’s script doesn’t apply, of course!
Do you know if there’s a way to make a Tagged item automatically be assigned a particular label? If so, all my problems are solved!
Thank you again…