Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Command-line conversion of flac+cue files to mp3 split tracks
#!/bin/sh
# Flacon-style convert to mp3 and split tracks from flac+cue files
# Made by André Rendeiro (afrendeiro@gmail.com)
# Rename
{
find . -name '* *' | while read file; do target=`echo "$file" | sed 's/ /_/g'`; mv "$file" "$target"; done
find . -name '* *' | while read file; do target=`echo "$file" | sed 's/ /_/g'`; mv "$file" "$target"; done
find . -name '* *' | while read file; do target=`echo "$file" | sed 's/ /_/g'`; mv "$file" "$target"; done
} >/dev/null 2>&1
# Find all flac files
for file in `find -name '*.flac'`.flac
do
file=`echo "$file" | sed 's/.flac//g'`;
# Convert FLAC to MP3 VBR
flac -cd $file.flac | lame -h - -v \
--preset cd $file.mp3
# Split file
mp3splt -q -a -c $file.cue -o @n.\ @t $file.mp3
#Remove files
rm $file.mp3
rm $file.cue
rm $file.flac
rm $file.log
done
for file in `find ./ -iname "*.jpg"`
do
filename=`basename $file`
cap=`echo "$filename" | python -c "print raw_input().capitalize()"`;
path=`echo "$file" | sed "s/$filename//"`
mv $file `echo "$path$cap"`
done
# Fix encoding
convmv -r --notest -f windows-1255 -t UTF-8 *
# Remove stupid files
for file in `find ./ -iname "IMPORTANT_NOTE.txt"`; do rm $file; done
for file in `find ./ -iname "Thumbs.db"`; do rm $file; done
# Rename back
{
find . -name '**' | while read file; do target=`echo "$file" | sed 's/_/ /g'`; mv "$file" "$target"; done
find . -name '**' | while read file; do target=`echo "$file" | sed 's/_/ /g'`; mv "$file" "$target"; done
find . -name '**' | while read file; do target=`echo "$file" | sed 's/_/ /g'`; mv "$file" "$target"; done
} >/dev/null 2>&1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment