12

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?

slm
  • 363,520
  • 117
  • 767
  • 871
evamvid
  • 688
  • 4
  • 10
  • 21

1 Answers1

30

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}"
done

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
slm
  • 363,520
  • 117
  • 767
  • 871