oplaTech About Teaching Archive
Oplatek's external memory

How to measure length of MP3 or any other wav files?

Command to print name and the length. (Btw. You need to build sox with mp3 codec for just adding MP3 to sox recognized filetypes)
find fbooks -name '*.MP3' -print -exec  soxi  -D {} \; 
Produces output like
first_found.MP3 
4.100998
second_found.MP3
4.336009
...
...

...
I used Python to join the 2 lines together to produce
first_found.MP3 4.100998
second_found.MP3 4.336009
...
...

...
Following Python snippet sums the lengths

find fbooks -name '*.MP3' -print -exec  soxi  -D {} \; \| 
python -c 'import sys; print sum([float(l) for i, l in enumerate(sys.stdin) if i % 2 == 1]) / 3600.0'