View Single Post
thanks for this script, I've been using it a lot.
I modified a couple things that didn't work for me:
-- added loop so the task durations would display as, say, 3 hours 15 minutes instead of just 3.25
--display a dialog box with the total time now instead of copying to the clipboard, also the number of items selected is shown
-- handle the sort "boxes" in context view so I can just select all and have it display the total estimated time for all my actions


modified version:
Code:
-- 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 (jwb1970@gmail.com), 2008-24-10
-- largely based on RobTrew's StartTimer.scpt Ver 0.02 for code to adds up durations of selected tasks (http://forums.omnigroup.com/showthread.php?t=4748)
-- and on hint from a11en in thread Minuteur Applescript for Growl Notification. (http://forums.omnigroup.com/showthread.php?t=6749)
-- James O'Leary (jpo@me.com), 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.
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)
					
					
					try
						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
		end tell
	end tell
	set lngHours to 0
	repeat
		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 "
else
	set strPluralHours to " hours "
end if
if lngMinutes = 1 then
	set strPluralMinutes to " minute."
else
	set strPluralMinutes to " minutes."
end if

display dialog "Item count: " & lngTrees & "
" & "Total time: " & (lngHours) & strPluralHours & lngTotal & strPluralMinutes