Home > Techie > Converting your m4a music files to mp3

Converting your m4a music files to mp3

Have you found yourself in posession of music or audio files that were in m4a format and wanted them as mp3’s?

Well good thing it quite easy to convert them.

Here is a quick script I have made to do just that:

#!/bin/sh
# converting multiple m4a files to mp3 and removing the created wav’s.
for i in *.m4a; do faad “$i”; done
for i in *.wav; do lame “$i” “$i.mp3″ && rm “$i”; done
rename .wav.mp3 .mp3 *.mp3

I like doing it in a few different steps, so I can check the .wav’s for quality, compression and corruption before converting them to mp3’s, that is why the processes are split up.

Here is what each line is doing:
for i in *.m4a; do faad “$i”; done
Is taking each m4a file, running faad on it, which is outputting it to a wav file (the file name will actually be .m4a.wav) which is fine since we’ll be doing another round of conversions anyway. This one is keeping the original m4a files ( I do that just in case the conversion to mp3’s have lots of quality loss, or corruption). If you want to remove them while it converts them you can use this line instead:
for i in *.m4a; do faad “$i” && rm “$i”; done

On to the next command:
for i in *.wav; do lame “$i” “$i.mp3″ && rm “$i”; done
Now we are grabbing each .wav file converting them from .wav to .mp3 using lame and removing the original .wav files (I don’t care about these, since I can easily recreate again using the first command). You will notice these are named with .wav.mp3 (this was just the simplest way to keep the script clean for people to understand), so we can fix that easily with the rename command.

Lastly we just want to clean up the naming of these files, so we run:
rename .wav.mp3 .mp3 *.mp3
Which is renaming all mp3’s that have the portion .wav.mp3 to only .mp3.

I hope at least one person finds this helpful.


Categories: Techie Tags:
  1. Alexandra
    June 30th, 2008 at 02:03 | #1

    That person being me? ;-)
    This es really helpful stuff, thanks!

  2. DJ
    June 30th, 2008 at 03:03 | #2

    Well thats 2 persons! So you just doubled the outcome of your expectation. Not bad :)

    Thanks!
    DJ

  3. Anzhr
    June 30th, 2008 at 03:30 | #3

    Thanks.

  4. September 27th, 2008 at 00:01 | #4

    May be helpful. But people like me will feel complicated. Why not use a software to convert m4a to mp3. It’s more simple.

  5. ben.kevan
    October 15th, 2008 at 16:39 | #5

    faad and lame are pieces of software that I am utilizing to do the conversion.

    The script is only used to do a full directory and changing the names etc.

    Pretty simple IMO, and it ships with most linux distributions.

  6. March 1st, 2009 at 13:49 | #6

    is there a forum on the site?

  7. March 1st, 2009 at 21:14 | #7

    Dai,

    Currently no.. But I’m working on that portion right now (phpbb).. I just have to re-skin it.

    Thanks.

    Also, is that your site? Please contact me if it is.

  8. April 15th, 2009 at 06:47 | #8

    Not that I’m impressed a lot, but this is more than I expected for when I found a link on Digg telling that the info here is awesome. Thanks.

  9. TheOneIsAmongUs
    June 7th, 2009 at 08:27 | #9

    How do I run this?

  10. June 7th, 2009 at 21:44 | #10

    @TheOneIsAmongUs

    You can either make a shell script with the commands above, or copy them into your terminal. Linux is a requirement here though. Not sure what type of machine you are on.

    Thanks

  1. July 8th, 2008 at 00:53 | #1