Skip to content

Instantly share code, notes, and snippets.

@aliva
Created April 6, 2017 11:04
Show Gist options
  • Save aliva/279f9f3e51f5a00b54f4338060bc572f to your computer and use it in GitHub Desktop.
Save aliva/279f9f3e51f5a00b54f4338060bc572f to your computer and use it in GitHub Desktop.
#!/bin/bash
function displaytime {
local T=`echo $1 / 1 | bc`
local D=$((T/60/60/24))
local H=$((T/60/60%24))
local M=$((T/60%60))
local S=$((T%60))
(( $D > 0 )) && printf '%d days ' $D
(( $H > 0 )) && printf '%d hours ' $H
(( $M > 0 )) && printf '%d minutes ' $M
(( $D > 0 || $H > 0 || $M > 0 )) && printf 'and '
printf '%d seconds\n' $S
}
export SUM=0
find | while read file
do
duration=`ffprobe -i "$file" -show_entries format=duration -v quiet -of csv="p=0"`
if [[ $? -eq 0 ]] && [[ $duration != "N/A" ]]
then
SUM=`echo $SUM + $duration | bc -l`
echo $SUM $file $duration
displaytime $SUM
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment