Thanks so much… I’m just starting to understand how to use scripts, so I’ll tinker w/ script to try to make it work. Hope it can work… If not, I’ll dash off a follow up question.
You ask a totally reasonable question. In short, it relates to another post I submitted re: how to automate a process whereby prefixes could be applied to files that corresponded to certain applied labels (High, Medium, Low priority). @korm very generously provided the following script:
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
It works perfectly, and brilliant helps me triage my files. But…I was just trying to get it to work with tags; right now it just works with labels. So, it seemed to me that if I could figure out how a process to automatically label a file that has a corresponding tag (a “Low” tag would receive a “Low” label), then I could retain the functions provided in @korm’s script. I’m happy to consider another process…I welcome any other suggestions.
I’ve asked this just because…I find that it’s preferable to Label files that are already in DTP, but it’s also easier to Tag files that I’m saving into DTP (esp. web files). That’s all…
Thanks, guys!