Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have some .mp4 and .m4a audio files that I want to convert to .mp3 files. I want the resulting .mp3 files to include the cover art included in the source files, without fiddling with EasyTAG manually. How can I do this?

share|improve this question
up vote 6 down vote accepted

I've written a script that will do this automatically. Just run the script against each .m4a or mp4 file, like this, and it will produce the .mp3 files in the same directory: *.mp4 *.m4a

You'll need to install these dependencies:

sudo apt-get install realpath libav-tools atomicparsley eyed3

Here's the script. Copy and paste this content and save it to a file named


set -e

for filename in "$@" ; do
    if [[ "$filename" == -* ]] ; then
        printf "Filename %s must not begin with a dash\n" "$filename" 1>&2
    printf "Converting %s\n" "$filename"
    filename=$(realpath "$filename")
    directory=$(mktemp -d)
    output="$(basename "$filename" | sed 's/\.[^.]*$//').mp3"
    cd "$directory"
    avconv -i "$filename" "$output"
    ln -s "$filename" "$(basename "$filename")"
    AtomicParsley "$(basename "$filename")" --extractPix || true
    shopt -s nullglob
    for imagefilename in *.jpg *.png *.JPG *.PNG ; do
        eyeD3 --add-image="$imagefilename":FRONT_COVER "$output" 
    shopt -u nullglob
    mv "$output" "$(dirname "$filename")"
    cd "$cwd"
    rm -r "$directory"
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.