Search code examples
bashmacosmp3ringtoneafconvert

Using afconvert command line tool to convert .mp3 files to m4r


I have a short bash script that is meant to convert a folder full of .mp3 files to .m4r ringtones. I am having trouble figuring out why it is throwing the following error:

"Error: ExtAudioFileCreateWithURL failed ('fmt?')"

#!/bin/bash

cd "/path/to/directory/containing/mp3s"

for i in *.mp3; do
    baseFilename=$( basename ${i} .mp3 )
    afconvert -f m4af ${i} -o "/path/to/new/location/${baseFilename}.m4r"
done

exit 0

Solution

  • The issue was that I had not specified the output data format. Found a helpful page that lead me to the answer:

    http://support.moonpoint.com/os/os-x/audio/afconvert.php

        #!/bin/bash
    
    cd "/path/to/directory/containing/mp3s"
    
    for i in *.mp3; do
        baseFilename=$( basename "${i}" .mp3 )
        afconvert -f m4af "${i}" -d aac "/path/to/new/location/${baseFilename}.m4r"
    done
    
    exit 0