Skip to content

Instantly share code, notes, and snippets.

@kitchen
Created June 16, 2013 02:07
Show Gist options
  • Save kitchen/5790466 to your computer and use it in GitHub Desktop.
Save kitchen/5790466 to your computer and use it in GitHub Desktop.
uses avconv to convert .flac files to .alac. Is case-friendly and will skip files it has already converted. public domain where applicable. Come on, it's a 27 line bash script!
#!/bin/bash
downloaddir=$1
if [[ -z "$downloaddir" ]]; then
echo "fatal, no arguments given"
exit 99
fi
find "$downloaddir" -iname '*.flac' | while read flac; do
echo "found $flac"
dirname=`dirname "$flac"`
basename=`echo -n "$flac" | sed 's/\.flac$//i'`
basename=`basename "${basename}"`
fname="${dirname}/${basename}"
if ! [[ -f "${fname}.m4a" ]]; then
echo "alac "${fname}.m4a" doesn't exist, creating"
avconv -i "$flac" -acodec alac -- "${fname}.part.m4a"
if [[ "$?" -eq "0" ]]; then
mv -- "${fname}.part.m4a" "${fname}.m4a"
echo "success!"
else
echo "eek, something went awry: $?"
fi
else
echo "file was already converted, skipping"
fi
done
@goodparterbless
Copy link

I use iDealshare VideoGo to batch convert FLAC to ALAC, it supports directly drag the FLAC forlder and then convert them at a time.

And it has both Mac version and Windows and also can convert FLAC to MP3, WAV, AIFF, AAC, WMA, and etc.

Step by step guide at http://www.idealshare.net/audio-converter/flac-to-apple-lossless.html

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