How to split album into different flac and tag them under Gentoo Linux

  |   Source

Install necessary CLI tools

sudo emerge media-sound/shntool
sudo emerge cuetools

Download the script

See https://bbs.archlinux.org/viewtopic.php?id=58766 for the source of bash script.

Here is the full content of the bash script:

#!/bin/bash

# split image file (flac, ape, wav, etc.) according to cue-file

if [ -f "$1" ]; then i=0 for cuefile in .cue; do i=$(($i + 1)) done if [ $i -eq 1 ]; then # precies 1 cuesheet gevonden if grep -q "INDEX 01 00:00:00" .cue ; then nice shntool split -t "%n %t" -f .cue "$1" else echo "The first track has a pre-gap. Shntool will cut that off and put it in a seperate file." echo "You don't want that. Please modify the cuesheet from:" grep -m1 "INDEX 00" .cue grep -m1 "INDEX 01" *.cue echo "to:" echo " INDEX 01 00:00:00" exit 1 fi elif [ $i -eq 0 ]; then echo "No cuesheet found in the current directory." exit 1 elif [ $i -gt 1 ]; then echo "$i cuesheets found in the current directory. Please remove the superfluous cuesheets." exit 1 fi else echo "Split image file (flac, ape, wav, etc.) according to cue-file." echo "Output files are in FLAC." echo "Usage: basename $0 <image-file>" exit 1 fi

echo

album=grep -m 1 TITLE *.cue | cut -d\" -f2

artist=grep -m 1 PERFORMER *.cue | cut -d\" -f2

for file in [0-9]*.wav; do echo "Encoding $file"

<span style="color: #b9ca4a;">if</span> [[ ${<span style="color: #e7c547;">file</span>:0:1} == 0 ]] ; <span style="color: #b9ca4a;">then</span>
    <span style="color: #e7c547;">tracknr</span>=${<span style="color: #e7c547;">file</span>:1:1}
<span style="color: #b9ca4a;">else</span>
    <span style="color: #e7c547;">tracknr</span>=${<span style="color: #e7c547;">file</span>:0:2}
<span style="color: #b9ca4a;">fi</span>
<span style="color: #e7c547;">title</span>=<span style="color: #c397d8;">`echo ${file:2} | sed -e "s/.wav$//"`</span>

nice flac -s -T <span style="color: #70c0b1;">"artist=$artist"</span> -T <span style="color: #70c0b1;">"album=$album"</span> -T <span style="color: #70c0b1;">"title=$title"</span> <span style="color: #70c0b1;">\</span>
-T <span style="color: #70c0b1;">"tracknumber=$tracknr"</span> <span style="color: #70c0b1;">"$file"</span> &amp;&amp; rm <span style="color: #70c0b1;">"$file"</span>

done

Put the script somewhere and name it to "cue2flac"

Do the real conversion

# convert the ape to corresponding wav file, for example, "a.ape" is converted to "a.ape.wav"

find . -name '*.ape'|xargs -I {} ffmpeg -i {} {}.wav

# split wav and convert it to flac, make sure the *.cue exists in current directory

cue2flac a.ape.wav

# do the cleaning (OPTIONAL)

rm .ape .wav

Comments powered by Disqus