Home > OS >  splitting cued audio files in command line with xld on osx
splitting cued audio files in command line with xld on osx

Time:11-08

I'm writing a script for batch processing audio files, with xld. I want to find unsplitted albums, split them and convert them in flac, with the proper tags.

find . -name "*.ape" -exec sh -c 'exec xld  "$1" -f flac' _ {} \;

this command line is converting the audio to flac but i have to add "-c filename.cue" option with xld to make it split the file.

find . -name "*.ape" -exec sh -c 'exec echo $1 | sed 's/.ape/.cue/'' _ {} ;

this command line shows me the path of .cue files

find . -name "*.ape" -exec sh -c 'exec xld "$1" -f flac -c $1 | sed 's/.ape/.cue/'' _ {} ;

this command line doesn't work, xld says he didn't found de cue file. i think it's just a syntax problem.

thanks for your help

CodePudding user response:

I'm not at a computer to test this like I normally would, but in bash you can substitute the trailing part of a variable like this:

thing="fred.ape"
echo ${thing/%.ape/.cue}
fred.cue

It's called "parameter substitution/expansion" and is explained with examples here.

So, based on that, you'd need to exec bash something like this (UNTESTED):

find . -name "*.ape" -exec bash -c "xld  "$1" -f flac -c "${1/%.ape/.cue}"' _ {} \;

Personally, I'd do them all in parallel with GNU Parallel like this:

parallel xld {} -f flac -c {.}.cue ::: *.ape

You can install it with homebrew using:

brew install parallel
  • Related