tell application "OmniFocus"
set theDoc to default document
tell theDoc
set allAvailable to count (every available task of every flattened context)
set errandsAvailable to count (every available task of context named "errands")
set actualAvailable to allAvailable - errandsAvailable
end tell
end tell
I couldn’t find an easy way. Hints, @omnigroup? :D
Counting tasks under a specific folder
I came out with this: set nInFolder to count (every available task of every flattened context where name of containing project's folder = "FolderName")
If you don’t have more than two layers of contexts (in other words, Errands > Grocery, but not Errands > Grocery > Circle K), then you could find all the other contexts whose stuff you need to count with
set errandContext to context named "Errands" set errandChildren to every flattened context whose container is errandContext
You’re actually making the same assumption with your folder solution. It won’t find a project that’s inside a folder that’s inside of “FolderName”
In fact, I have this one extra level of contexts (Errand > Groceries > Circle K). Only way then would be iterating over Errands and its sub-contexts? Not familiar with that. Trying to find a way.
For now, I’ve set with the Folder based solution (no sub Folders there), but the solution would be much more elegant, and flexible, if I managed to find a(n efficient) way to count the Errands (context) tasks.