Converting your m4a music files to mp3

Sunday, June 29th, 2008 | Techie

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.



6 Comments to Converting your m4a music files to mp3

Alexandra
June 30, 2008

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

DJ
June 30, 2008

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

Thanks!
DJ

Anzhr
June 30, 2008

Thanks.

[...] good thing it quite easy to convert them.Here is a quick script I have made to do just that:http://www.benkevan.com/blog/converting-your-m4a-music-files-to-mp3/free convert m4a to mp3Convert m4a to mp3 software . convert audio cd to mp3 . Burn mp3 to CD. To [...]

Emma
September 27, 2008

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

ben.kevan
October 15, 2008

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.

Leave a comment

Search

Polls

Do you think having RDP on a Linux Host important in the enterprise space?

View Results

Loading ... Loading ...

Powered by