tags and Spotlight

Is there any way to convert tags into Spotlight comments, or to make DT tags searchable from Spotlight? I know you can convert Spotlight comments to tags, but I can’t see a way to do the converse. Thanks.

Try this. It appends the tags to the existing Spotlight comments. In addition, the script prompts you for an optional prefix for tags (e.g., @ or &, etc.). Some programs will recognize delimited words in Spotlight comments as tags. If you don’t want the prefix, leave it blank when prompted.

The script is not smart enough to detect if the comments already include the tags. So do not run this more than once on a given document.

-- append DT tags to Spotlight comments

tell application id "com.devon-technologies.thinkpro2"
		set these_items to the selection
		if these_items is {} then error "Please select some contents."
		set the_prefix to text returned of (display dialog "Enter a prefix for each tag, or leave blank" default answer "")
		repeat with this_item in these_items
			set these_tags to the tags of this_item
			set this_comment to the comment of this_item
			if this_comment is not "" then set this_comment to this_comment & " "
			repeat with this_tag in these_tags
				set this_tag to the_prefix & this_tag & " "
				set this_comment to this_comment & this_tag
			end repeat
			set the comment of this_item to this_comment
		end repeat
	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

Thanks, I’ll give it a try