Skip to content

Instantly share code, notes, and snippets.

@aliva
Last active December 13, 2015 02:54
Show Gist options
  • Save aliva/1038a42c779b0f69c471 to your computer and use it in GitHub Desktop.
Save aliva/1038a42c779b0f69c471 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# apt-get install lame flac shnsplit cuetools
# create temp dir
rm -rf flac_to_mp3_tmp
mkdir -p flac_to_mp3_tmp
if [[ `ls *.flac | wc -l ` == 1 ]]
then
# if there is only one file it should be splited
shnsplit -d flac_to_mp3_tmp -o flac -f *.cue -t "%n - %t" *.flac
else
# if there is more than one flac file in current dir
# assume it's already splitted
cp *.flac flac_to_mp3_tmp --verbose
fi
# convert to mp3
cd flac_to_mp3_tmp
for f in *.flac
do
flac -cd "$f" | lame -b 320 - "${f%.*}".mp3
done
cd ..
# add tags to mp3 files
cuetag *.cue flac_to_mp3_tmp/*.mp3
# move mp3 file to root dir
mv flac_to_mp3_tmp/*.mp3 .
# remove tmp dir
rm -rf flac_to_mp3_tmp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment