View Single Post
Would you be happy if the text was just capitalized like a sentence? Only the initial alphabetic character would be capitalized...

Code:
property pCapitalizeFirstWord : true -- Make first alphabetic character uppercase, edit to false if not wanted

-- Prepend text to selected actions
tell application "OmniFocus"
	tell front document
		tell document window 1
			set oTrees to selected trees of content
			set lngTrees to count of oTrees
			if (lngTrees > 0) then
				set strPrepend to text returned of (display dialog ¬
					"String to prepend to selected actions" default answer "" buttons {"OK", "Cancel"} default button "OK")
				
				if (pCapitalizeFirstWord) then
					set strPrepend to my Capitalize(strPrepend)
				end if
				repeat with iTree from 1 to lngTrees
					set oTask to value of (item iTree of oTrees)
					set name of oTask to strPrepend & name of oTask
				end repeat
			else
				display alert "No content selected!"
			end if
		end tell
	end tell
end tell

on Capitalize(txt)
	return do shell script "python -c \"import sys; print unicode(sys.argv[1], 'utf8').capitalize().encode('utf8')\" " & quoted form of txt
end Capitalize