~smlavine/scripts

ref: 8ec12e5ae617f4262b1ee630a7bc1a4cc4d31bff scripts/src/musicsum -rwxr-xr-x 447 bytes
8ec12e5aSebastian LaVine Shorten lines to less than 80 chars 6 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
#!/bin/sh
# Copyright (c) 2021 Sebastian LaVine <mail@smlavine.com>
# Licensed under the MIT license. See MIT.txt for details.
#
# File:        musicsum
# Description: Sums the length of given audio files.
# Arguments:   Audio files to sum the duration of

mediainfo "$@" |
	grep Duration | tr -s ' ' | cut -d' ' -f'3,5' |
	awk 'NR % 2 != 1 { sum += $2; sum += $1*60 }
	END { printf "%dh%dm%ds\n",
		sum / (60*60), sum % (60*60) / 60, sum % 60 }'