Report abuse


			
property delim : " - "

on open (s)
	display dialog "Enter tags:" buttons {"Cancel", "OK"} default answer "" default button "OK"
	set result to text returned of result
	set theResult to result as text
	tell application "GrowlHelperApp"
		-- Make a list of all the notification types 
		-- that this script will ever send:
		set the allNotificationsList to ¬
			{"Spotlight comments"}
		
		-- Make a list of the notifications 
		-- that will be enabled by default.      
		-- Those not enabled by default can be enabled later 
		-- in the 'Applications' tab of the growl prefpane.
		set the enabledNotificationsList to ¬
			{"Spotlight comments"}
		
		-- Register our script with growl.
		-- You can optionally (as here) set a default icon 
		-- for this script's notifications.
		register as application ¬
			"SpotlightCommenter" all notifications allNotificationsList ¬
			default notifications enabledNotificationsList ¬
			icon of application "Script Editor"
	end tell
	tell application "Finder"
		repeat with this_item in s
			set item_name to (get displayed name of this_item)
			if item_name is not ".DS_Store" then
				set current_com to (get comment of this_item)
				if current_com does not contain theResult then
					if current_com is "" then
						set comment of this_item to theResult
						
					else
						set comment of this_item to (current_com & delim & theResult) as string
						
					end if
					tell application "GrowlHelperApp"
						notify with name ¬
							"Spotlight comments" title ¬
							item_name description ¬
							"Tagged \"" & theResult & "\"" application name "SpotlightCommenter"
					end tell
				else
					tell application "GrowlHelperApp"
						notify with name ¬
							"Spotlight comments" title ¬
							item_name description ¬
							"Already tagged \"" & theResult & "\"" application name "SpotlightCommenter"
					end tell
				end if
				
			end if
		end repeat
	end tell
end open