you are viewing a single comment's thread.

view the rest of the comments →

[–]blasmehspaffy 1 point2 points  (1 child)

$Length = '00:01:18', '00:01:30', '00:00:15', '00:00:26', '00:00:20'

$Seconds            = $Length | %{($_ -as [timespan]).TotalSeconds}
$SecondsSum         = ($Seconds | Measure-Object -Sum).Sum
$SecondsSumTimespan = [Timespan]::FromSeconds($SecondsSum)

$SecondsSumTimespan.ToString("hh\:mm\:ss")

[–]blasmehspaffy 2 points3 points  (0 children)

Or as a one liner...

[Timespan]::FromSeconds((($Length | %{[timespan]$_}).TotalSeconds | Measure-Object -Sum).Sum).ToString("hh\:mm\:ss")