So I'm trying to convert lots of m4as to mp3s, and I think the best way to do that is using avconv.

The problem is, I can't seem to find any solid examples on how to use avconv.

Looking at the man page, it has a ridiculous amount of flags/options, and I can't make sense of it.

How can I batch convert with avconv?


To do a single file:

$ avconv -i m.m4a m.mp3

To do a batch you could wrap this in a for loop:

$ for i in *.m4a; do
    avconv -i "$i" "${i/.m4a/.mp3}"

This will take all the files that are present in the current directory with the extension .m4a and run each of them through avconv. The 2nd argument, ${i/.m4a/.mp3} does a substitution on the contents of the variable $i, swapping out .m4a for .mp3.

NOTE: As a one liner:

$ for i in *.m4a; do avconv -i "$i" "${i/.m4a/.mp3}"; done
  • How could I consolidate that loop onto one line? Or would it be easier to just put it in a shell script? – evamvid Apr 20 '14 at 4:17
  • @evamvid - see update. – slm Apr 20 '14 at 5:28
  • I ended up putting it in a shell script last night, but thanks! – evamvid Apr 20 '14 at 20:47
  • 1
    @evamvid - OK. If your issues been resolved can you please mark this A as accepted so other passerby's know that your issue's been resolved. – slm Apr 20 '14 at 22:40
  • yeah, just did. – evamvid Apr 20 '14 at 23:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.