I wanted to know the total duration of a couple of mp3 files, using onboard tools of a Mac. Thanks to StackOverflow, it’s as simple as:
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))}'
Obviously, I could have figured this out in a couple of seconds by reading some man pages. But searching the web was even more convenient. So I leave it up to you to figure out what exactly the above commands are doing. Alternatively, just use soxi :) .