Skip to content

Instantly share code, notes, and snippets.

@sorokine
Forked from jesseadams/flac2mp3
Created March 31, 2013 20:30
Show Gist options
  • Save sorokine/5281900 to your computer and use it in GitHub Desktop.
Save sorokine/5281900 to your computer and use it in GitHub Desktop.
#!/bin/bash
convert_dir=$1
output_dir=$2
bitrate=$3
# Ensure require params are passed in
if [ -z $convert_dir ] || [ -z $output_dir ];
then
echo "Usage: flac2mp3 rip_dir output_dir [bitrate]"
exit
fi
# Default to 320 kbps if bitrate not specified
if [ -z $bitrate ];
then
bitrate=320
fi
# Get the list of files to convert
files=( `find $convert_dir -iname '*.flac' | tr "\n" " "` )
# Convert each file, one at a time
for file in ${files[*]}
do
flac -dc $file | lame -b $bitrate - $output_dir/`basename $file`.mp3
done
echo "Conversions complete!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment