in applescript

OmniFocus script: Get total time of selected items

2017–04–23 Update: Fixes an issue that could cause the script to fail if certain top-level perspective separators are selected.

2011–07–06 Update: If you downloaded the script before 18 July 2011, there was a bug that could cause an additional hour to be added to the time. That issue is fixed in the current version.

Total Time.png

Here’s a script to sum the total time of selected items in OmniFocus. Just select some items, fire it off and see how overcommitted you are.

Download it here.

For those with something to say:



  1. Thanks for the script. Just one problem: I just selected two actions, one of 30min and another of 10min … on Growl teh output is 1h 40min?! Where did this 1h come from?


  2. 30mins…

    It seems that after 30min the script adds the 1h.

  3. Hi. Thanks so much for this script! I love it and use it regularly. I recently encountered a problem that I hope you can help with.

    From the Perspectives menu, I chose “All Items.” The totals for all my tasks was 56 hours 21 minutes for 1027 items.

    When I change it to be in context mode, I use the view bar to change it so that things are ungrouped AND availability is set to any status. This time when I run the script for the total time, it shows 56 hrs 21 minutes 886 items.

    The time is the same – but not the number of items. Why would this be?

    Thanks so much. Leila

  4. Hi Leila,

    The script will count all selected items (excluding the Grouping folders), including projects if they’re showing. So in your project view if you select the following:

    – Action 1
    – Action 2

    …the script will count three items. But switching to context mode, you may only see the actions, so that would be counted as two items.

    Hope this helps.

  5. I have never wanted to buy someone a beer more then I do right now. Thank you for making this gem! Review process just elevated to Über!

  6. Dan! I owe you a mint chocolate chip ice cream cone. Fantabulous script! Thanks so much for offering it up!

    One issue: while I can run the script from the applescript editor (by hitting the play button after I select some actions in OF), I can’t do it from the installed script in the OF script folder.

    Basically right now I’m a loser and I want to be a winner like you guys! :)

    I followed these instructions to a tee:

    The script is in the right place (I think): ~/Library/Scripts/Applications/OmniFocus/Total Time.scpt

    So when I click on the scripts menu bar icon, the script shows up as an OF script. I click that puppy, and my OF window flashes, but nothing happens.

    Any ideas? I’m going to restart. If that fixes it, I’ll report back. :)

  7. Just restarted. No bueno. I still get a flash then no report. Tried it with growl on and off. No notification whatsoever. I’m on OS X 10.6.8 & OF 1.10.3.

    PS: “you’re at this website. i guarantee it.” -dan byler That? Brilliant. Am I buttering you up? Yes. But. It’s true. :)

  8. This is amazing! I just installed it tonight and it still works perfectly! A couple comments: 1. in Omnifocus 2 goto help -> “Open Scripts Folder” 2. copy the script that location.

    Most people might know this but it took me some time so I thought I would share the knowledge.

  9. I get an error message. My Mac won’t even let me save this script, much less use it. I get error message -1,752 when I try to save it. I don’t know what that means.

  10. Hi,

    Very useful, thanks for sharing.

    Is there any way to make it work even when the selection contains a top-level item “Today” or “Next week” etc. that appears when sorting by due? It gives an error when you just do “Cmd+A” and run the script on everything; you carefully have to de-select all the top-level “time items” first.

    Best regards, Gandalf Saxe

  11. Hi! This looks great, but I am a complete noob. How do I use this? I can download the folder, and I have dragged it into the scripts folder for OF2, but I don’t understand how to get it to do anything or make it show up to pull into the toolbar. I just have a folder that contains a bunch of script files… Any help would be much appreciated!

  12. Hi Dan, Thank your for this great script. May I suggest that, beyond notification window, the script adds the total time info to the Estimated time of each active project. I think that would be of a great help. Best regards,

  13. Thanks for the kind words, Paul.

    As for your suggestion, I think I can see why it would be useful (OmniFocus doesn’t currently show project tallies, which was the impetus for creating the script in the first place).

    Unfortunately, hardcoding the total as a project estimate would complicate things and have some adverse consequences. Say we start with

    Project A: - Task A1 (5m) - Task A2 (5m)

    Project B: – Task B1 (5m) – Task B2 (5m)

    If you select all projects and run the script, you’ll see 20m total for these items. But if the script were to modify the projects…

    Project A (10m): - Task A1 (5m) - Task A2 (5m)

    Project B (10m): – Task B1 (5m) – Task B2 (5m)

    …next time you run the script it would claim a total time of 40m. This could be addressed, of course:

    • The script could become “smart” about choosing to include only tasks (or projects), which may or may not be correct depending on how you use estimates
    • The user could be surgical about which items to select before running the script

    There might be other solutions as well. But either way, it would add complexity and I’d need to think through it very carefully before trying something like that.

  14. How to get the Apple Script Folder of OmniFocus. Go to help menu, there is one item with something “Show me Apple Script Folder”

    The New Path is ( 16.01.18 ) ~/Library/Application Scripts/com.omnigroup.OmniFocus2.MacAppStore/HERE PUT YOUR SCRIPT

    Now it is available at the Toolbar.

  15. I’ve made extensive use of this script—thank you! I just updated to OF 3.0 for macOS, and also updated to macOS Mojave. I’ve copied Total Time.applescript to the OmniFocus 3 scripts folder and installed it on the toolbar. But when I run the script, I get the error message:

    “./Library/Application Scripts/com.omnigroup.OmniFocus3/Total Time.applescript:1840:1847: execution error: The variable context is not defined. (-2753)”

    Any suggestions for how to fix this? Thanks again.

  16. Hello Dan,

    thanks a lot for this Script. It worked well and nice in OmniFocus 2. Now i changed to OmniFocus 3. It got some changes on OF3, that the AS isn’t working on this version.

    Cheers Chris

  17. Thanks for this script, Dan! It’s become integral to my work flow.

  18. Hi Dan, Was pointed in this direction via a live session with Joe Buhlig. However, I can’t make the script work. I get the below error message both when running it in OmniFocus or from FastScript. Any ideas to make i work?

    The operation couldn’t be completed. /Users/fdx247/Library/Application Scripts/com.omnigroup.OmniFocus3/Total Time.applescript:1840:1847: execution error: The variable context is not defined. (-2753)

  19. Hi Lars, you must be using an older version of the script that refers to “contexts”, which OmniFocus now calls “tags”. Options:

    1) Open the script in Script Editor. Search and replace “context” with “tag” 2) Download an updated version of the script from

    Cheers, Dan