#!/bin/sh set -e get_duration() { ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 "$1" | awk '{print int($1+0.5)}' } [ -z "$1" ] && { echo "usage: $0 FILENAME [FILENAME ...]" echo " or: $0 *.mp4" exit 1 } total=0 while [ $# -gt 0 ]; do if [ -f "$1" ]; then dur=$(get_duration "$1") total=$(( total+dur )) else >&2 echo "error: $1: no such file" exit 1 fi shift done echo "$total seconds" days=$(( total / 86400 )) if [ $days -gt 0 ]; then echo -n "${days}d " fi human="$(date -d@$total -u +%H:%M:%S)" echo "$human"