#!/bin/bash join() { local IFS="$1" shift echo "$*" } #### ARCHIVE readarray -t durations < <( find /var/www/nextcloud/data/radio_admin/files/archive/. -type f \( -iname '*.mp3' -o -iname '*.wav' -o -iname '*.m3u' -o \ -iname '*.m4[ab]' -o -iname '*.mpga' -o -iname '*.opus' \) \ -exec ffprobe {} -show_format -loglevel -8 \; | sed -nE 's/^duration=([0-9\.]+)$/\1/p') # add + between all durations: expression=$(join + ${durations[@]}) # calculate the total, including subseconds, round to whole minutes: totM=$(bc -q <<< "scale=0;($expression)/60") totH=$(bc -q <<< "scale=0;($totM)/60") totJ=$(bc -q <<< "scale=0;($totH)/24") timestamp=$(date) echo "$timestamp : Total duration of Pl4tform-Archives: $totM minutes / $totH Hours / $totJ Days" >> ./ARCHIVE_music_duration_output.txt