The Omni Group Forums

The Omni Group Forums (http://forums.omnigroup.com/index.php)
-   OmniFocus Extras (http://forums.omnigroup.com/forumdisplay.php?f=44)
-   -   Script: Toggling the status of taskless folders (http://forums.omnigroup.com/showthread.php?t=25993)

RobTrew 2012-10-01 10:19 AM

Script: Toggling the status of taskless folders
 
Not sure how widely useful this will be, but I had a reason today to think about toggling the status of folders which contain projects but no tasks (or no available tasks). Toggling them automatically, in other words, back and forth between [I]Active[/I] and [I]Dropped[/I].

(One probably needs to set the sidebar filter to All Projects while doing this, to see what's going on)

CAUTION: ILLUSTRATIVE ONLY - NOT RECOMMENDED FOR PRACTICAL USE - THIS MAY TOGGLE BACK INTO LIFE SOME DROPPED FOLDERS WHICH YOU HAD HOPED TO NEVER SEE AGAIN. STUDY IT CAREFULLY AND MAKE SURE THAT YOU UNDERSTAND IT BEFORE YOU THINK OF USING IT.

Not fast (perhaps there is a better way ?) but feasible:

[CODE]property pblnHidden : false

-- Toggle the status of folders from which NO TASKS descend
on run
set pblnHidden to not pblnHidden

tell application id "OFOC"
tell default document
repeat with oFolder in (flattened folders where its effectively hidden ≠ pblnHidden) as list
set refProjects to (a reference to (flattened projects of oFolder where number of tasks > 0))
if ((count of refProjects) < 1) then set hidden of oFolder to pblnHidden
end repeat
end tell
end tell
end run[/CODE]

or, to toggle the status of folders which enclose no available tasks:

[CODE]property pblnHidden : false

-- Toggle the status of folders from which NO TASKS descend
on run
set pblnHidden to not pblnHidden

tell application id "OFOC"
tell default document
repeat with oFolder in (flattened folders where its effectively hidden ≠ pblnHidden) as list
set refProjects to (a reference to (flattened projects of oFolder where number of available tasks > 0))
if ((count of refProjects) < 1) then set hidden of oFolder to pblnHidden
end repeat
end tell
end tell
end run[/CODE]


All times are GMT -8. The time now is 01:58 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.