How to script garbage collection?

Hi, I suspect this is really easy but I have not yet dabbled in scripting. I have a high number of recurring tasks in Omnifocus, some daily, some weekly, some monthly, etc. For most (not all) of these tasks, I do not track comments or progress. What I would like to do is have a way of identifying them, e.g. by having a Tag “Garbage Collect” and then having a script that looks for all Completed tasks with that tag, and automatically deletes them. The task could run daily, or whenever I open Omnifocus, or on some other trigger.

I suspect this is straightforward to do. I would appreciate any pointers on how to get started. thank you in advance!

Greetings! Perhaps this will work?

1 Like

thank you Sal. That description does look like it will fit my use case with a quick addition (to filter for Status=Completed). I will do some investigating on how to setup as a script within my Omnifocus. I really appreciate the pointer!

Click the Download Plug-In button in the example to get the plug-in!

I’m no OmniJS expert but I did have one that I made in Keyboard Maestro. I hit my hot key and watch Keyboard Maestro do its work.

I have a custom perspective called “Cleanup” that shows all completed tasks that have the “Disposable” tag:

Screen Shot 2022-05-03 at 08.25.48

Then I created a Keyboard Maestro macro:

I have it set to a keyboard shortcut but it’s easy enough to set it to start on a timer trigger:

Screen Shot 2022-05-03 at 08.28.54

It goes to the Cleanup perspective, selects all the tasks (if any) in the outline and then deletes it.