3

I want to remove the album art that is embedded in a bunch of MP3s (thousands) and cannot find a command-line way to do this. I can add art via lame and I can add or remove pretty much any other tags with id3tag but I can’t find a way to do something like:

for file in **/*.mp3 do <remove image command> $file; done

Anyone know what I might put in for <remove image command>?

1

5 Answers 5

5

There does not appear to be a good solution, and the best that I came up with was using ffmpeg to quickly create a new file. The command that @awesome14 provided did not work for me on my system (mostly it did, but it generated many errors and that resulted in songs that were not copied). This is the command I came up with.

for song in **/*.mp3
   do NAME=$(echo ${song%/*} | sed -e 's|[/ ]|-|g’)
      ffmpeg -y -i $song -vn -c copy /path/NOART/"$NAME-"${song##*/}; 
done

This works with a bash5 or zsh shell.

  1. **/*.mp3 Every file matching .mp3 in every directory under the current

  2. echo ${song%/*} | sed -e 's|[/ ]|-|g’ convert all slashes and spaces in the path portion (not in file name) to dashes

  3. —vn -c copy Do not copy video (video no) and otherwise copy the file unmodified

  4. /path/NOART/"$NAME-"${song##*/} save to the path with the filename set to the NAME variable and the base name of the $song.

  5. Output filename will look like "10Cc-Look-Hear-Dressed To Kill.mp3”.

This has the additional advantage of not removing all the metadata in the song, only stripping the “video” which in this case is the album cover art.

1
  • bash: unexpected EOF while looking for matching `''
    – ar2015
    Commented May 23, 2023 at 12:51
5

@BowlOfRed rightly points to a straightforward answer using the eyeD3 package in their comment.  If it's just a single file,

eyeD3 --remove-all-images filename.mp3

and tailored to the original question,

for file in **/*.mp3; do eyeD3 --remove-all-images "$file"; done

or even

eyeD3 --remove-all-images **/*.mp3

Of course, the “globstar” shell option must be set for “**” to work as in these examples.

1

You can install kid-cli, which can be used to change metadata tags from the CLI. I'd never used it to remove Album Arts before seeing this question, but I think I've figured out how:

for file in **/*.mp3 do (sleep 2; printf %s\\n 'set "Picture:" ""' save exit) | kid3-cli $file; done

Although it is a cli program, kid3-cli is meant to be used interactively. For this reason, commands are expected to be typed interactively. Also, for some reason, the above command doesn't work unless there is a delay. If you have a whole bunch of files to process, perhaps you could mitigate this by running the command on multiple files in parallel.

for file in **/*.mp3 do (:; (sleep 2; printf %s\\n 'set "Picture:" ""' save exit) | kid3-cli $file)&; done; wait

Or:

(sleep 2; printf %s\\n 'set "Picture:" ""' save exit; sleep 2) | kid3-cli *.mp3; done

In the latter case, kid3-cli needs a delay after the commands have been piped in, too. IDK why, but at least you can process all of your files at once.

PS: I don't have any mp3 files to test this with, so I used some ogg/vorbis files. Since ogg uses a different tagging system (vorbis comment) than mp3 (id3), this might work the same on both formats. However, This *should* work fine for mp3s anyway.

1
  • thousands of files do not lend themselves to a interactive tool, sadly. just the delay 2 for each file would require 7 hours.
    – lbutlr
    Commented Dec 30, 2020 at 16:13
0

There are many methods available using 'ffmpeg'. However, to list and explain them all on an online Q&A site would not be practical or appropriate. There are different mp3 files that require different techniques to be used with ffmpeg.

There are also several different ways to remove art from mp3 files, using ffmpeg, depending on your objective. Certain users want a smaller file size, while others want to simply prevent displaying the art, because they might want it later, so they don't want to get rid of it.

The ffmpeg documentation makes it easy to drill down and find exactly what you want.

ffmpeg -i tagged.mp3 -write_xing 0 -id3v2_version 0 untagged.mp3

is but one method. That would be put inside a 'for loop' to do all the files.

4
  • You might want to add a -c copy argument to ffmpeg. Otherwise the process could suck up a lot of CPU, and the audio quality will be reduced. Commented Dec 30, 2020 at 6:46
  • ffmpeg requires creating a new file so doesn’t actually allow removing the art work from the mp3, it allows creating a new file with no artwork. This is my desperate-nothing-else-works-solution, but I want something that just strips the artwork from the existing files.
    – lbutlr
    Commented Dec 30, 2020 at 16:10
  • error: Attached pictures were requested, but the ID3v2 header is disabled..
    – ar2015
    Commented May 23, 2023 at 12:53
  • I get the same error as @ar2015
    – Diagon
    Commented Feb 24 at 10:38
0

Install kid3

$ pacman -Ss kid3
community/kid3 3.9.1-2 [installed]
    An MP3, Ogg/Vorbis and FLAC tag editor, KDE version

And run the script:

#!/bin/bash

for filename in ./*.mp3; do
    echo $filename
    kid3-cli -c 'set Picture ""' $filename
done
2
  • Explain your script!!! Which should help those ho refer.
    – AReddy
    Commented Apr 11, 2022 at 5:04
  • This was already posted by @TSJNachos117 though perhaps kid3-cli has removed the need for a delay since Dec 2020?
    – lbutlr
    Commented Apr 24, 2022 at 21:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .