From: Colin P. McCabe Date: Sat, 4 Jun 2022 00:30:08 +0000 (-0700) Subject: audible-to-mp3.sh: check for mp3splt, use gfind X-Git-Url: http://www.club.cc.cmu.edu/~cmccabe/cgi-bin/gitweb.cgi?p=cmccabe-bin;a=commitdiff_plain;h=9d3f243e756dcd94797aefdb11fb478e6cded042 audible-to-mp3.sh: check for mp3splt, use gfind --- diff --git a/audible-to-mp3.sh b/audible-to-mp3.sh index 1b2054d..6af8f4a 100755 --- a/audible-to-mp3.sh +++ b/audible-to-mp3.sh @@ -21,6 +21,13 @@ $0: convert Audible .aax files to mp3s. EOF } +# On MacOS, use gfind since AAXtoMP3 needs it. +FIND=find +which gfind &> /dev/null +if [[ $? -eq 0 ]]; then + FIND=gfind +fi + debug=0 while getopts "a:dhi:o:" flag; do case $flag in @@ -37,6 +44,7 @@ shift $((OPTIND-1)) which AAXtoMP3 &> /dev/null || die "Failed to locate AAXtoMP3. Please install it." which audiobooker &> /dev/null || die "Failed to locate audiobooker. Please install it." which tagger.py &> /dev/null || die "Failed to locate tagger.py. Please install it." +which mp3splt &> /dev/null || die "Failed to locate mp3splt. Please install it." [[ -v authcode ]] || die "You must specify the authcode." [[ -v input ]] || die "You must specify the input file." [[ -f "${input}" ]] || die "Not a normal file: ${input}" @@ -57,7 +65,7 @@ AAXtoMP3 --authcode "${authcode}" --single "${tmpdir}/input.aax" # For some reason, AAXtoMP3 doesn't give us much control over the output file name. # Let's find out what it is using the "find" command, and change it to something well-behaved. pushd "${tmpdir}" &> /dev/null || die "failed to pushd ${tmpdir}" -find -name '*.mp3' -type f -print0 | xargs -0 -I{} mv {} "${tmpdir}/input.mp3" +$FIND -name '*.mp3' -type f -print0 | xargs -0 -I{} mv {} "${tmpdir}/input.mp3" popd &> /dev/null [[ $? -eq 0 ]] || die "Failed to locate and move the AAXtoMP3 output." mkdir -p "${tmpdir}/output" || die "failed to create ${tmpdir}/output directory"