This post originated from an RSS feed registered with Ruby Buzz
by Ryan Davis.
Original Post: Removing duplicates from OmniFocus
Feed Title: Polishing Ruby
Feed URL: http://blog.zenspider.com/index.rdf
Feed Description: Musings on Ruby and the Ruby Community...
Sometimes something (I suspect iSync) screws up and duplicates my tasks. This has proven useful:
tell application "OmniFocus"
tell first document
repeat with aContext in contexts
set toDelete to {}
set seen to {}
repeat with aTask in tasks of aContext
if seen contains name of aTask then
set end of toDelete to id of aTask
else
set end of seen to name of aTask
end if
end repeat
repeat with aTask in toDelete
try
delete (task id aTask)
end try
end repeat
count of toDelete
end repeat
end tell
end tell