Adding up durations of flagged/selected tasks

To make sure I’m not too ambitious, I’m looking for a way to add up durations of all flagged/selected/perspective tasks.

Any scripts/solutions?

Away from my Mac, but I think this is the one I still use. Regardless, @dbyler’s work is always great to learn from!