~smlavine/scripts

ref: d01b5e637b661425887f3a353ee4b69365c796ec scripts/src/musicsum -rwxr-xr-x 450 bytes
d01b5e63Sebastian LaVine musicsum: Remove early exit 6 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
#!/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 } '