Return to Snippet

Revision: 61565
at December 21, 2012 13:41 by ianthekirkland


Initial Code
tell application "DEVONthink Pro"
	set sel to the selection
	if (count of sel) is 1 then
		tell application "System Events"
			set devon_think to application process "DEVONthink Pro"
			set tag_bar to text field 1 of splitter group 1 of group 1 of splitter group 1 of splitter group 1 of window 1 of devon_think
			set focused of tag_bar to true
		end tell
	else
		-- More than 1 item is selected, add tags to selection via script dialog --
		tell application id "com.devon-technologies.thinkpro2"
			try
				set theSelection to the selection
				if theSelection is {} then error "Please select some items."
				
				repeat
					set theTag to display name editor "Add Tags" info "Tags (separated by semicolons):"
					if theTag is not "" then exit repeat
				end repeat
				
				set {od, AppleScript's text item delimiters} to {AppleScript's text item delimiters, ";"}
				set theTags to text items of theTag
				repeat with theRecord in theSelection
					set tags of theRecord to (parents of theRecord) & theTags
				end repeat
				set AppleScript's text item delimiters to od
			on error error_message number error_number
				if the error_number is not -128 then display alert "DEVONthink Pro" message error_message as warning
			end try
		end tell
	end if
end tell


Initial URL

                                

Initial Description

                                

Initial Title
DTP-Add Tags to Selection of Single or Multiple Items

Initial Tags

                                

Initial Language
AppleScript