With the change in OmniFocus forums, the upgrade to OmniFocus 2 and changes in the OS itself, I’ve been unable to find a script that will provide OF statistics (total numbers for projects, tasks, contexts etc, plus numbers of those with a particular status like completed, on-hold etc.) I know that at the bottom of the Settings page, it lists the total number of projects and actions (in my case 119 and 1395 which illustrates why I am trying to get a handle on this sort of thing) but that simply refers to the total number of projects and actions without regard to their current status (e.g. active, completed, on hold, dropped).
A search pulls up Rob Trew’s thread from four years ago but with him not seen on the forums recently and all the changes as mentioned above, I’m unsure whether his script works.
Is there a central repository of all the OmniFocus scripts? Is there some functionality on the Mac or iPad version that provides the information and I just need to RTFM?
What I have is likely not exactly what you want. It just gives a % complete report. It does not count number of tasks and projects and so on. But it may be useful in any case.
In addition, I have an OF script called Quick Stats Ver. 2.03 that will most definitely give you what you want. You might find it here …
I have no clue why I can never get the copy + paste of code to work properly.
(*
This script tallies a percentage completion on all projects in rightmost panel window
*)
property pTitle : “Completion Status” – title of dialog box
property pLine : "-> " – starting string for a line
property pEmpty : “-0-” – three character string for empty projects
tell application id “OFOC”
tell front document window of default document
set its perspective name to "Projects"
-- collect all content in sidebar
repeat with oPanel in {content, sidebar}
set lstProj to (value of every tree of oPanel where (class of its value is project and status of its value is active))
set lngProj to length of lstProj
if lngProj > 0 then exit repeat
end repeat
if lngProj < 1 then return
-- generate the completion status list
set str to ""
-- loop through all projects
repeat with oProj in lstProj
tell oProj
set strn to " : " & its name
set lngDone to 0
-- flatten the task list of the project
set lstTasks to the (flattened tasks of oProj as list)
set lngTasks to number of items in lstTasks
if lngTasks > 0 then
-- we have tasks in the project
-- count the completed number of tasks
repeat with oTask in lstTasks
if oTask is completed then
set lngDone to lngDone + 1
end if
end repeat
-- generate the percentage complete
set pcTask to (((lngDone / lngTasks) * 100) as integer)
if (pcTask < 10) then
set strp to pLine & " " & (pcTask as string) & "%" & tab
else if (pcTask < 100) then
set strp to pLine & " " & (pcTask as string) & "%" & tab
else
set strp to pLine & (pcTask as string) & "%" & tab
end if
else
-- we have no tasks in the project
set strp to pLine & pEmpty & tab
end if
end tell
set str to str & strp & strn & return
end repeat
display dialog str buttons {"OK"} default button "OK" with title pTitle
end tell
That is a cool script, @DrJJWMac. I’ve collected the script sections in your last post into one code block for posterity.
(*
This script tallies a percentage completion on all projects in rightmost panel window
*)
property pTitle : "Completion Status" -- title of dialog box
property pLine : "-> " -- starting string for a line
property pEmpty : "-0-" -- three character string for empty projects
tell application id "OFOC"
tell front document window of default document
set its perspective name to "Projects"
-- collect all content in sidebar
repeat with oPanel in {content, sidebar}
set lstProj to (value of every tree of oPanel where (class of its value is project and status of its value is active))
set lngProj to length of lstProj
if lngProj > 0 then exit repeat
end repeat
if lngProj < 1 then return
-- generate the completion status list
set str to ""
-- loop through all projects
repeat with oProj in lstProj
tell oProj
set strn to " : " & its name
set lngDone to 0
-- flatten the task list of the project
set lstTasks to the (flattened tasks of oProj as list)
set lngTasks to number of items in lstTasks
if lngTasks > 0 then
-- we have tasks in the project
-- count the completed number of tasks
repeat with oTask in lstTasks
if oTask is completed then
set lngDone to lngDone + 1
end if
end repeat
-- generate the percentage complete
set pcTask to (((lngDone / lngTasks) * 100) as integer)
if (pcTask < 10) then
set strp to pLine & " " & (pcTask as string) & "%" & tab
else if (pcTask < 100) then
set strp to pLine & " " & (pcTask as string) & "%" & tab
else
set strp to pLine & (pcTask as string) & "%" & tab
end if
else
-- we have no tasks in the project
set strp to pLine & pEmpty & tab
end if
end tell
set str to str & strp & strn & return
end repeat
display dialog str buttons {"OK"} default button "OK" with title pTitle
end tell
end tell