Auto split files using cue during import

578 views
Skip to first unread message

Kyle Hall

unread,
Sep 1, 2016, 8:49:19 AM9/1/16
to beets
Hello all!

So, I have some albums that are single flac files with cue and log files. Is there any way to have beets split these into individual flac files per song during the import process? I've been searching for the answer for days and haven't come up with an answer.

Thanks!
Kyle

Karcsi Kolbasz

unread,
Sep 1, 2016, 12:05:34 PM9/1/16
to beets
Not sure of how many of these you have, but it might be easier to pre process with foobar2000 or medieval cue splitter. That's how I have handled it in the past.

MBony

unread,
Sep 1, 2016, 4:07:46 PM9/1/16
to beets
I have used CUETools for this in the past few days.  It was also a relatively easy process.

Tijl Van Assche

unread,
Sep 2, 2016, 3:10:08 PM9/2/16
to beets
Hi

If you're on Linux and prefer to do it via cli, you may find this script I wrote useful. Just pass the cue and flac file as arguments and optionally a destination directory for the flac files. As stated in the usage function, you need cuetools, shntool and flac installed.
It's not exactly what you're asking for as it doesn't integrate with beets in any way, but I guess it can be a starting point if you have many albums to split and want to automate that task before doing a beet import.

Tijl



#! /bin/bash
# Split one flac file into tracks using cuetools.
# Requires: cuetools shntool flac
set -eu

function usage {
  echo "Usage: ${0##*/} [-d DEST] FILE.cue FILE.flac"
  echo "  -d DEST     destination (defaults to working directory)"
  echo
  echo "Requires cuetools, shntool and flac."
}


[[ -z $@ ]] && usage && exit 0


# get the options
while getopts ":d:" opt
do
  case $opt in
    d)  DESTDIR="${OPTARG}" ;;
    ?)  echo "Illegal option: $OPTARG" ;;
  esac
done
shift $(( OPTIND-1 ))


# validate args
err=0
if [[ $# -ne 2 || "${1: -4:4}" != .cue || "${2: -5:5}" != .flac ]]
then
  usage && err=$(( err+1 ))
else
  [[ ! -e "$1" ]] && echo "No such file: $1" >&2 && err=$(( err+2 ))
  [[ ! -e "$2" ]] && echo "No such file: $2" >&2 && err=$(( err+3 ))
fi
(( $err )) && exit $err


# split the flac file
CUESHEET="$1"
FLACFILE="$2"
DESTDIR="${DESTDIR:-.}"

mkdir -p "${DESTDIR}"
shnsplit -d "${DESTDIR}" -f "${CUESHEET}" -o flac -t "$$_%n %t" "${FLACFILE}"
cuetag.sh "${CUESHEET}" "${DESTDIR}"/$$_*.flac

for pid in "${DESTDIR}"/$$_*.flac
do
  nopid=$(echo "${pid}" | sed "s,/${$}_,/,")
  mv -i "${pid}" "${nopid}"
done


# vim:ts=2:sts=2:sw=2




--
You received this message because you are subscribed to the Google Groups "beets" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beets-users...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Tonya Rabish

unread,
Apr 5, 2019, 4:35:28 AM4/5/19
to beets
 To split FLAC into multiple FLAC segments or split FLAC into MP3 segments, we recommend you to choose Avdshare Audio Converter, the best FLAC cue splitter approved by many users.
Reply all
Reply to author
Forward
0 new messages