AppleScript for Estimated Time of Custom Perspectives

Good morning,

I am trying to create an Apple Script that will add up the estimated time for two custom perspectives. I would really like it if I could also remove any tasks after 6p.

As an added bonus, I would love to pull the amount of times that I am in meetings from on of my calendars (I have a Google & my corporate syncing to Mac Calendar - I am only interested in my Corporate).

Ultimately, my goal would be to get a better view of my day by adding up estimated time for two perspectives during the workday hours then subtracting my meeting commitments to show me how overbooked I am for the day quickly.

I am not really sure how to go about this as I am very new to AppleScript. Any help or direction would be appreciated.



1 Like

Take one step at a time. Use the editor in β€œlive” mode and watch the results. Look for snippets of examples to modify rather than trying to write everything yourself from scratch. In this vein, here is a script that will pull all the tasks in a custom perspective and put them in a list with their name and time (minutes).

property pName : "Work" -- set this to the perspective name

on run {}
set ActionList to {}
tell application "OmniFocus"
	tell front document window of default document to set its perspective name to pName
	tell content of front document window of default document to set TreeList to (value of every leaf)
	repeat with theAction in TreeList
		if (estimated minutes of theAction is missing value) then
			set span to 0
			set span to estimated minutes of theAction
		end if
		set end of ActionList to {name:name of theAction, min:span}
	end repeat
end tell
end run


1 Like

Thanks. With your suggestions & starting point, I was able to get it working pretty much the way I want it.

Thanks again.