--- /dev/null
+#!/usr/bin/env bash
+
+die() {
+ echo $@
+ exit 1
+}
+
+usage() {
+ cat <<EOF
+mp3chop.sh: divide up mp3s into managable pieces.
+
+usage: mp3chop.sh: [options] <mp3 names>
+
+options:
+-h: show this help message.
+-o [dir]: output directory to use.
+-s [size]: segment size to use (default: 5minutes).
+EOF
+}
+
+which mp3splt &> /dev/null || die "you must have mp3splt installed"
+
+segment_size=5.0
+output_dir="./out"
+while getopts "ho:s:" flag; do
+ case $flag in
+ h) usage; exit 0;;
+ o) output_dir=$OPTARG;;
+ s) segment_size=$OPTARG;;
+ *) echo "getopts error"
+ echo
+ usage
+ exit 1;;
+ esac
+ #echo "$flag" $OPTIND $OPTARG
+done
+
+shift $(( OPTIND-1 ))
+
+mkdir -p "$output_dir" || die "failed to create $output_dir"
+
+for file in "$@"; do
+ absfile="$(readlink -f "${file}")"
+ mkdir -p "${output_dir}/${file}.dir"
+ pushd "${output_dir}/${file}.dir" &>/dev/null \
+ || die "failed to pushd to ${output_dir}/file"
+ ln "$absfile" || die "failed to hardlink ${absfile}"
+ mp3splt -t "${segment_size}" "${file}" \
+ || die "mp3splt failed on file ${file}"
+ rm -f "$file"
+ mv * ..
+ cd ..
+ rmdir "${file}.dir" || die "rmdir ${file}.dir failed"
+ popd &> /dev/null || die "popd failed"
+done
+
+echo "*** SUCCESSFULLY SPLIT ALL ***"