Skip to content

Instantly share code, notes, and snippets.

@wissehes
Last active October 10, 2022 14:17
Show Gist options
  • Save wissehes/87ede4cb6ae6b7ce67a8ef9695c729b6 to your computer and use it in GitHub Desktop.
Save wissehes/87ede4cb6ae6b7ce67a8ef9695c729b6 to your computer and use it in GitHub Desktop.
A simple bash script for converting FLACs to ALAC files.
#!/bin/bash
# A simple bash script for converting FLACs to ALAC files.
# For example: ./flac2alac.sh flacs alacs
# Where "flacs" and "alacs" are the input and output directories respectively.
in=$1
out=$2
echo $in
# if [ $# -eq 0 ]
if [ -z "$in" ]; then
echo "No input provided"
exit 1
elif ! [ -d "$in" ]; then
echo "Input is not a directory."
exit 1
fi
if [ -z "$out" ]; then
echo "No output provided"
exit 1
elif ! [ -d $out ]; then
echo "Output is not a directory."
exit 1
fi
files="$in/*.flac"
for file in $files; do
# echo $file
newFileName=${file%.flac}.m4a
fileNameWithoutPath=${newFileName##*/}
# echo $fileNameWithoutPath
ffmpeg -i "$file" -c:v copy -c:a alac "$out/$fileNameWithoutPath"
done
echo "Done!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment