View Single Post
If anybody's interested, I made two minor changes to the (modified) script:

1) removed the "cancel" button from the dialog because it's not necessary (plus, clicking it gives an error)

2) the total time (in minutes) is added to the clipboard. When pasted into omnifocus, this number takes the appearance of "__h __m" like you'd expect

-- Sum estimated times, display sum in Growl and copy sum to clipboard (for later pasting back into estimated time for an entire project, or elsewhere).
-- Jake Bowers (, 2008-24-10
-- largely based on RobTrew's StartTimer.scpt Ver 0.02 for code to adds up durations of selected tasks (
-- and on hint from a11en in thread Minuteur Applescript for Growl Notification. (
-- James O'Leary (, 2008-08-11 
-- now can handle context view "boxes) (assigned an estimated time of 0) and the time displayed is in hours and minutes instead of
-- just a straight up hours number. Displays in dialog box now instead of copying to clipboard. Item count displayed as well.
-- Aaron Hunyady (, 2009-08-01
-- Removed "cancel" button in dialog. Total time in minutes is copied to the clipboard.
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 lngTotal to 0
				repeat with iTree from 1 to lngTrees
					set oTask to value of (item iTree of oTrees)
						set lngMinutes to estimated minutes of oTask
					on error
						set lngMinutes to 0
					end try
					if lngMinutes as string is equal to "missing value" then
						set lngMinutes to 0
					end if
					set lngTotal to lngTotal + lngMinutes
					--do shell script "/usr/local/bin/growlnotify OmniFocus  -m 'Total time " & lngTotal & " minutes' -p 1"
				end repeat
			end if
			set the clipboard to lngTotal as rich text
		end tell
	end tell
	set lngHours to 0
		if lngTotal < 60 then exit repeat
		set lngTotal to lngTotal - 60
		set lngHours to lngHours + 1
	end repeat
end tell
if lngHours = 1 then
	set strPluralHours to " hour "
	set strPluralHours to " hours "
end if
if lngMinutes = 1 then
	set strPluralMinutes to " minute."
	set strPluralMinutes to " minutes."
end if

display dialog "Item count: " & lngTrees & "
" & "Total time: " & (lngHours) & strPluralHours & lngTotal & strPluralMinutes buttons {"OK"} default button 1