Skip to content

Instantly share code, notes, and snippets.

@mlen
Last active April 23, 2024 07:02
Show Gist options
  • Star 26 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save mlen/4379799 to your computer and use it in GitHub Desktop.
Save mlen/4379799 to your computer and use it in GitHub Desktop.
FLAC to ALAC converter. Requires Mac OS X and `flac` binary installed (ie. via Homebrew: `brew install flac`).
#!/usr/bin/env bash
set -e
convert_to_alac() {
flac="$1"
aiff="${flac%.*}.aiff"
alac="${flac%.*}.m4a"
flac -s -d --force-aiff-format -o "$aiff" "$flac"
afconvert -f m4af -d alac "$aiff" "$alac"
rm "$aiff"
}
if [ $# -ne 1 ]; then
echo "usage: $0 dir"
echo "requirements: Mac OS and flac installed"
exit 1
fi
for file in "$1"/*.flac; do
echo -n "."
convert_to_alac "$file"
done
echo " done"
@mattsawyer77
Copy link

thanks for this.

@dbrisinda
Copy link

Very helpful. Thanks.

@johan
Copy link

johan commented Dec 4, 2017

If you want to port over track metadata and cover art too, https://superuser.com/a/543662 is even handier.

@richmindlearn
Copy link

You may also use iDealshare VideoGo to convert FLAC to ALAC without quality loss.

It also helps to convert ALAC to FLAC and convert between FLAC, ALAC, M4A, WAV, MP3, AAC, WMA, OGG, OPUS etc

It also helps to extract FLAC, ALAC from video files or convert between video formats.

Here is the easy guide https://www.idealshare.net/audio-converter/flac-to-apple-lossless.html

@alvarow
Copy link

alvarow commented Jun 18, 2020

I don't think you need Homebrew or to install anything... here's how I do it on Mojave and Catalina:

export IFS=$'\n'
for x in `ls *.flac`; do afconvert -v -f m4af -d alac $x ${x%flac}m4a; done

@rovo79
Copy link

rovo79 commented Jul 14, 2021

@alvarow

absolutely perfect. Had no idea afconvert just existed like that! Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment