OmniFocus delete Project Script?

Hello,

I’m trying to get an AppleScript that would cause any Completed OmniFocus projects with the word ROUTINE in the title to automatically be deleted. What would a script like that look like? I’m sure it is ridiculously simple and hopefully when I see it in front of me I can pick it apart to create new scripts based off of it easily.

Many thanks in advance.

Thanks, but even my incredibly novice scripting skills, or lack thereof, can see that the script there has to do with Files in the Finder not projects in OmniFocus. Did I, perhaps, not post in the right forum category?

Hello.

As a security measure, the project has to be completed, before it gets to be deleted.

set foundList to {}
tell application "OmniFocus"
	tell its front document
		set prjList to every project of it
		repeat with aprj in prjList
			considering case
				if name of aprj contains "ROUTINE" and completed of aprj is true then
					set end of foundList to contents of aprj
				end if
			end considering
		end repeat
		repeat with aprj in foundList
			delete aprj
		end repeat
	end tell
end tell

The day this script doesn’t do what is supposed to do, is the day your Omnifocus backup is corrupted. :slight_smile:

Hmm, could it be that my OmniFocus database is already corrupted?

I copied the script, compiled it in AppleScript Editor, saved it to /Users/~/Library/Scripts/Applications/OmniFocus, ran it and nothing.

I don’t think even I could have screwed it up on such a short trip.

Your project has to be completed in order for it to run, As a security measure.

Since you specified the “ROUTINE” in uppercase it has to be in uppercase.

If you have such a completed project with ROUTINE in it, and nothing happens, then I can’t help you.