I need to check the duration of a group of audio files. Is there a simple way to do this on the unix command-line?
> duration *
I have the a
In addition to cdosborn's answer, to calculate the length of all .mp3
files recursively in subfolders of current directory and show the total sum result in days:hours:minutes:seconds
format:
In zsh:
afinfo **/*.mp3 | awk '/estimated duration/ { print $3 }' | paste -sd+ - | bc | awk '{printf("%d:%02d:%02d:%02d\n",($1/60/60/24),($1/60/60%24),($1/60%60),($1%60))}'
In bash or sh:
find . -name "*.mp3" -exec afinfo {} \; | awk '/estimated duration/ { print $3 }' | paste -sd+ - | bc | awk '{printf("%d:%02d:%02d:%02d\n",($1/60/60/24),($1/60/60%24),($1/60%60),($1%60))}'
The result is like this (7 days, 5 hours, 6 minutes, 58 seconds):
$ afinfo **/*.mp3 | awk '/estimated duration/ { print $3 }' | paste -sd+ - | bc | awk '{printf("%d:%02d:%02d:%02d\n",($1/60/60/24),($1/60/60%24),($1/60%60),($1%60))}'
7:05:06:58
$