Local

..:: Home
..:: Legal
..:: Contact
..:: About
..:: RSS
..:: Log in

Links

..:: Fake Bill Gates
..:: Tap the Hive

A Random Quote

"Do or do not. There is no try." -- Yoda

MP3 Cue Splitter: splitall.sh

The purpose of this script is to take all cue files in a directory and split all mp3 files with matching names to the cue files into smaller mp3s based on the title and times of the mp3 in the cue file. since some DJ’s actually use the PERFORMER tag in cue files, the script automatically looks for the performer tag and adjusts as necessary.

For example, I download DJ GT’s latest release from generation trance. His latest release might be comprised of 3 or 4 sets. If I burn the mp3s straight to CD, I have a single 80 minute track, which sucks. If I burn the CD based on the cue file, there might happen to be a couple songs I don’t like on the set. So, I just run splitall.sh and I get some 40 mp3s to check out.

You may need to extend your repositories, but it’s in there.

sudo apt-get install mp3splt

Here’s the script:

#!/bin/bash
#############
# splitall 2006.3.21
# by david loschiavo
#
# REQUIRES: mp3split
# Put this script somewhere in $PATH like /usr/bin.
# if you run the script with no args, it will split all mp3s based
# on their matched name cues in the current directory.
# you can also pass arg1 as a directory to pull cues/mp3s and split there.
#
# assuming u put the script somewhere in $PATH, some examples are
#    splitall.sh
#             splits all cue/mp3 in the present working directory
#    splitall.sh somedir
#             splits all cue/mp3 in somedir
#
# if you do not put the script in $PATH, you will need to use:
#
#    ./splitall.sh
#             splits all cue/mp3 in the present working directory
#    ./splitall.sh somedir
#             splits all cue/mp3 in somedir
#
#############

echo "splitall.sh: v2006.3.21 by David Loschiavo "
echo "splitall.sh: read beginning of script for help"

if [[ $1 != "" ]]
then
        OLD_DIR=$PWD
        cd $1
else
        echo “splitall.sh: no args specified, executing in present working directory”
fi

has_mp3splt=`whereis mp3splt`
if [[ $has_mp3splt == "mp3splt:" ]]
then
        echo “splitall.sh: Sorry, but this script requires mp3splt, and it could not be located.”
        echo “splitall.sh: Make sure it is in $PATH or try one of these:”
        echo “splitall.sh:   Gentoo: emerge mp3splt”
        echo “splitall.sh:   Ubuntu: sudo apt-get install mp3splt”
        echo “splitall.sh:   Debian: apt-get install mp3splt”
        echo “splitall.sh:   Other: get a better distro and reformat”
        exit 0
fi

for file in *.cue
do
        if [[ $file == "*.cue" ]]
        then
                echo “splitall.sh: no cue files found, exiting”
                exit 0
        fi
        title_length=`expr ${#file} - 4`
        title=${file:0:$title_length}
        perf_count=`grep -i PERFORMER “${title}.cue” | wc -l`
        if [[ $perf_count > 1 ]]
        then
                mp3splt -o “@p - @t” -c “${title}.cue” “${title}.mp3″
        else
                mp3splt -o “@t” -c “${title}.cue” “${title}.mp3″
        fi
done

if [[ $1 != "" ]]
then
        cd $OLD_DIR
fi

echo “splitall.sh: splitting completed”
exit 0

Leave a Reply