check duration of audio files on the command-line

ted.strauss picture ted.strauss · Jan 19, 2012 · Viewed 36k times · Source

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 amazing SoX app which has an option called stats that generates a set of audio info including duration. I am looking for a way to get only duration. I am flexible on output format, could be any of sample length, hh:mm:ss, or seconds. The latter would be my preference.

Answer

ted.strauss picture ted.strauss · Jan 21, 2012
soxi -D filename
soxi -D *

Soxi queries metadata of audio files; D is the duration option. It supports globbing. Soxi's big brother sox does command-line audio processing.