I’m trying to count the number of projects in a folder.
I have figured out how to count all projects and tasks.
tell application "OmniFocus"
tell front document
set Folderlist to count of every flattened project
set taskList to count of flattened tasks
end tell
end tell
I would appreciate it if somebody could help me to figure out the counting in a particular folder bit…
Perhaps something like this (given a name change at the top):
on run
set folderName to "Publications"
tell application "OmniFocus"
tell default document
set matches to flattened folders where name is folderName
if {} ≠ matches then
set namedFolder to item 1 of matches
count of flattened projects of namedFolder
else
"No folder found with name matching '" & folderName & "'"
end if
end tell
end tell
end run
FWIW in a JavaScript idiom for Script Editor (rather than omniJS automation), you could flip the language selector at top left (from AppleScript to JavaScript) and try something equivalent like: