Skip to content

Instantly share code, notes, and snippets.

@rrroyal
Created February 22, 2020 19:28
Show Gist options
  • Save rrroyal/c32f5059197c923efbe639a743c3e58d to your computer and use it in GitHub Desktop.
Save rrroyal/c32f5059197c923efbe639a743c3e58d to your computer and use it in GitHub Desktop.
ZSH script used to convert FLAC files to ALAC using ffmpeg, preserving respective metadata.
#!/usr/bin/env zsh
if [[ "$1" == "" ]]; then
echo "No directory specified! Using \`pwd\`."
location=`pwd`
else
location="$1"
fi
if [[ "$2" != "" ]] ; then
map="$2"
else
map="0"
fi
for file in $location/**/*.flac; do
ffmpeg -i "$file" -map $map:0 -acodec alac "${file%.flac}.m4a"
if [[ "$?" == 0 ]]; then
rm "$file"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment