home  |  stuff I made  |  talks  |  try out all the things  |  meet  |  feed

Converting FLAC to Apple Lossless without the hassle

The problem:

  1. when I can choose between different audio formats to download, I prefer lossless to lossy (duh).
  2. the de-facto standard for lossless audio is FLAC.
  3. I am an inhabitant of Apple's iTunes/iPod/iPhone Garden Eden – and of course Apple refuses FLAC and instead cooked up their own lossless format, ALAC, which resides in .mp4 container files.

So every time I get hold of music in FLAC, I need to convert it to ALAC before I can throw it into iTunes. On average, UIs for small apps like these are horrible, so I'd prefer to have a Bash-script available for that.

First of all, the code is from an answer at AVP Stack Overflow.

Using Homebrew, we install ffmpeg:

$ brew update
$ brew install ffmpeg

I recommend sporting a scripts directory in the home folder, which is added to the [PATH]( We want to have a script there called which does the conversion whereever we have some FLAC files.


$ cd ~/scripts
$ touch     # genereates an empty file
$ chmod +x  # makes it executable

Then one edits that file in a text editor of choice and puts inside:

for f in *.flac; do ffmpeg -i "$f" -c:a alac "${f%.flac}.m4a"; done
# see and POST URL

What does this code do?

This will simply cycle through all the .flac files sitting in the current directory and convert them all to .alac until they're all done.

Done. Example?

Lets say you have a folder called 100-Million-Bon-Jovi-Fans-cant-be-wrong filled all the bestest music in flac files. Do

$ cd ~/Downloads/100-Million-Bon-Jovi-Fans-cant-be-wrong

Et voila.


  • does exist?
  • is it executable?
  • is it in ~/scripts?
  • is ~/scripts part of the PATH?
  • did you open a fresh terminal window after editing PATH?