Last active
December 21, 2015 03:38
-
-
Save ksysctl/6243207 to your computer and use it in GitHub Desktop.
Split cue into individual flac files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # | |
| # author: @gin, 2013 | |
| # url: | |
| # | |
| # split cue into individual flac files | |
| # | |
| # dependencies: | |
| # sudo apt-get install flac bchunk ffmpeg | |
| # | |
| # parameters: | |
| # path: directory where cue & ape files exits | |
| # prefix: base filename for individual flacs | |
| args=$#; | |
| path="$1"; | |
| prefix="$2" | |
| cue_file=""; | |
| ape_file=""; | |
| wav_file="output.wav"; | |
| function prepare() { | |
| if [ ${args} -eq 0 ]; then | |
| echo "Enter a path, sample: ${0} /path/to/cue/ape/files/ prefix"; | |
| exit 1; | |
| fi | |
| if [[ -d "${path}" && ! -L "${path}" ]]; then | |
| cd $path; | |
| else | |
| echo "Error entering to ${path}"; | |
| exit 1; | |
| fi | |
| if [ "${prefix}" == "" ]; then | |
| prefix="flacs"; | |
| fi | |
| for f in *.cue; do | |
| cue_file=$f; | |
| done | |
| if [ "${cue_file}" == "" -o "${cue_file}" == "*.cue" ]; then | |
| echo "CUE file not found"; | |
| exit 1; | |
| fi | |
| for f in *.ape; do | |
| ape_file=$f; | |
| done | |
| if [ "${ape_file}" == "" -o "${ape_file}" == "*.ape" ]; then | |
| echo "APE file not found"; | |
| exit 1; | |
| fi | |
| } | |
| function convert() { | |
| ffmpeg -i $ape_file $wav_file | |
| if [ $? -ne 0 ]; then exit 1; fi | |
| bchunk -w $wav_file $cue_file $prefix | |
| if [ $? -ne 0 ]; then exit 1; fi | |
| flac --best $prefix* | |
| if [ $? -ne 0 ]; then exit 1; fi | |
| rm -Rf *.wav | |
| } | |
| function main() { | |
| prepare; | |
| convert; | |
| } | |
| main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment