Let me start by saying that I recently switched from an iPhone to Android. When I wanted to put my music on my new phone I discovered that my new phones’ music player didn’t recognise the m4a in which many of my audio files were encoded. So I needed to find a way to convert my m4a files to mp3 without too much hassle. Being the developer that I am, I wanted to do this automatically without too much hassle.
I quickly found out how to do this and in this article I’ll share this information with you.
Step 1: Install ffmpeg
On OSX, you can use a simple tool called ffmpeg. Make sure you have homebrew installed on your Mac, and enter the following command in your terminal:
1 |
brew install ffmpeg |
Step 2: Convert it all!
And now for the magic. Enter your terminal, navigate to the folder from which you recursively want to convert all your m4a files, and execute the following command (please note that this can take a while, depending on how many songs you have):
1 |
find . -type f -name *.m4a -exec bash -c 'ffmpeg -i "$1" "${1/m4a/mp3}"' -- {} \; |
And if you want to delete the original m4a file in the process, add a simple rm command:
1 |
find . -type f -name *.m4a -exec bash -c 'ffmpeg -i "$1" "${1/m4a/mp3}" && rm "$1"' -- {} \; |
Visitors give this article an average rating of 4.9 out of 5.
How would you rate this article?
★ ★ ★ ★ ★
Thanks for this. Anyone coming across this: I had to add quotes ‘ ‘ around *.m4a to get it to work in macos.