6

I have a ton of music on my computer, but unfortunately it's in m4a, and steam only takes mp3.

Is there a program or a terminal command that will convert an entire folder?

12

This was fairly simple. First you'll need ffmpeg installed.

Then there's this simple terminal command you can use to convert all the audio files to MP3:

for f in *.flac , *.m4a , *.ogg ; do ffmpeg -i "$f" -ab 320k "${f%.m4a}.mp3"; done

Breakdown:

  • for f in *.flac , *.m4a , *.ogg ;: For every audio file of these types,
  • do ffmpeg -i "$f" -ab 320k "${f%.flac}.mp3";: Convert that file to MP3, get the next file.
  • If you want to change the bitrate, simply change the 320k in kbps.
  • You can change the filetypes it looks for simply with that comma-separated list of *.flac , *.m4a , *.ogg to whatever files ffmpeg can decode.
  • You can change the output name to whatever you want, "${f%.m4a}.mp3" could be "${f%}.mp3" or "${f%.audio}.mp3", f% represents the original filename.
| improve this answer | |
  • how do i specify the path? – user389450 May 8 '15 at 0:17
  • @thebluesquirel Simply cd directory first, so that you are in the directory where the music files are, then issue the command. To do another folder, just cd to that folder and run it again. – Robobenklein May 8 '15 at 0:19
  • ok thanks wasnt sure if i had to specify it in the command ,or if it would make the changes to the current directory. – user389450 May 8 '15 at 0:40
  • Just a note: avconv can replace ffmpeg straight away in this command. – 0xc0de Dec 1 '16 at 19:47