Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I am looking for a software in Linux, that will add the album-art/cover to each of the selected files in batch-mode. The album art is a jpg/png stored in my computer. It will be awesome if it can import from internet.

Currently I have tried both Rhythmbox and Banshee. I have also tried lame and easytag, but seems they do not support batch mode. lame is not adding the properties, but overwriting. (I know lame is the only command line s/w i have used so far).

So, basically I am looking for:

<some magic s/w> --picture=<my chosen picture> Music/Artist/*.mp3

That will add the picture to the metadata of the file, permanently.

Can you suggest me any such software?

share|improve this question

2 Answers 2

up vote 5 down vote accepted

lame

Using lame you can do this using a little scripting:

$ lame --ti /path/to/file.jpg audio.mp3

If the files are named something like this you can make a shell script to do what you want:

for i in file1.mp3 file2.mp3 file3.mp3; do
  albart=$(echo $i | sed 's/.mp3/.jpg/')
  lame --ti /path/to/$albart $i
done

You can make the above slightly more compact and eliminate the need for sed by using bash to do it by having it remove the matching suffix:

...
albart="${i%.mp3}.jpg"
...

Picard/MusicBrainz

If you want to do this on a large scale I'd suggest using Picard which is the frontend tool for using the MusicBrainz database. There is a plugin to Picard called "Cover Art Downloader", which can do this to batches of your collection.

The above doesn't appear to be command line driven however.

beets

Another option would be to use beets. This can be driven from the command-line and makes use of MusicBrainz database for sourcing the album art.

You can either source the album art usingFetchArt Plugin or embed it using the EmbedArt Plugin.

Other options?

Also take a look at this previously asked U&L Q&A titled: Which mp3 tagging tool for Linux?. There are several alternative tools listed in this thread.

share|improve this answer
    
You can avoid the sed call with something like albart="${i%.mp3}.jpg". More importantly, I just tested your lame command and got lame: unrecognized option -i... –  evilsoup Jul 30 '13 at 23:09
    
@evilsoup - thanks, the switch was missing a dash. Should be --ti ... –  slm Jul 30 '13 at 23:15
    
@evilsoup - also added your feedback on not using sed. Thanks! –  slm Jul 30 '13 at 23:24
    
Is it possible to remove the cover art with lame, too? –  Exeleration-G Dec 9 '13 at 10:09
3  
@Exeleration-G - no I wouldn't recommend using lame since it's actually an encoder. There are other tools for just manipulating the id3 tags of an mp3. You can use id3v2 -r "APIC" *.mp3 or eyeD3 --remove-all-images *.mp3 to remove any attached images. –  slm Dec 9 '13 at 13:34

One solution would be to use ffmpeg:

ffmpeg -i input.mp3 -i cover.jpg -map_metadata 0 -map 0 -map 1 output.mp3

You can put this in a for loop to do every MP3 in a directory:

for f in ./*.mp3; do ffmpeg -i "$f" -i cover.jpg -map_metadata 0 -map 0 -map 1 out-"${f#./}"; done

This will create a separate output file (so if you have a file called foo.mp3, you will end up with both foo.mp3 and out-foo.mp3); this is because ffmpeg cannot write over its input. You can fix this with something like:

for f in ./*.mp3; do \
ffmpeg -i "$f" -i cover.jpg -map_metadata 0 -map 0 -map 1 out-"${f#./}" \
&& mv out-"${f#./}" "$f"; done

Using ffmpeg for this problem is a little bit like using a cruise missile to crack a nut. More specialised metadata-manipulating tools will certainly be able to do this in a cleaner, shorter command.

share|improve this answer

Your Answer

 
discard

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.