Summary: id3tool, id3v2 and eyeD3 worked fine with find and xargs, see below for the specific syntax for each.
I could not get id3ren to work. All taken from Ubuntu's repository for 9.10 Karmic Koala.
I needed to tag a whole directory tree of MP3 files with the genre tag "Salsa". This blog post is about whether the above mentioned command line tagging tools worked as expected with find and xargs to batch add a tag. Results were checked with the EasyTag editor.
Now, a standard way in the shell on unixish systems to dig up files and pipe them to a command is something like this:
find -name "*.mp3" -print0 |xargs -0 tag-command --flags
- "find" finds all items and prints them out for you,
- the "-name "*.mp3" limits it to items ending in mp3,
- the "-print0" prints them in such a way that the next command in the chain does not get confused by any weird characters in the file names, achieved by putting a NULL character in between them. MP3 files often have weird file names. Do note that the -print0 command needs to come after the parameters to find!
"xargs" then executes tag-command for each item that find finds. The "-0" flag is to unpack the NULL delimited items xargs gets from find.
Here are the results:
find -name "*.mp3" -print0|xargs -0 id3tool -G Salsa
(no output generated on command line) id3tool worked like a charm.
find -name "*.mp3" -print0|xargs -0 id3ren -genre Salsa
*** No ID3 tag found in ./music - music.mp3
===> Entering new tag info for ./music - music.mp3:
id3ren just hanged there for at least ten minutes, at which point it was terminated by me. I copied the mp3 file it stopped on to another directory and ran id3tool on it as above, and it worked fine. Finally I also ran it on files that had already been tagged; it still reported "No ID3 tag found", and hanged.
find -name "*.mp3" -print0|xargs -0 id3v2 -g 143
(no output generated on command line) id3v2 worked like a charm.
eyeD3 also worked like a charm:
find -name "*.mp3" -print0|xargs -0 eyeD3 -G Salsa
a file.mp3 [ 7.85 MB ]
-------------------------------------------------------------------------------
Time: 04:51 MPEG1, Layer III [ ~225 kb/s @ 44100 Hz - Joint stereo ]
-------------------------------------------------------------------------------
No ID3 v1.x/v2.x tag found!
Setting track genre: Salsa
Writing tag...
ID3 v2.4:
title: artist:
album: year: None
track: genre: Salsa (id 143)
...and eyeD3 just chugged on like that, adding tags.
One difference between eyeD3 and the other working editors was that they stopped when being fed a faulty file path, while eyeD3 continued with the next path.
Update 2010-09-22
This blog posting has been completely rewritten after "jax" commented that the find command used had been wrong. I had treated "-print0" as just another flag to the find command. It is not, in fact when find encounters a "-print" or "-print0" command it prints right then and there, and any flags coming thereafter are ignored (unless another -print or print0 command follows them). This meant that my impression was that none of the editors worked, when in fact all but one did work.
I first tested like this:
find -print0 -name "*.mp3"|xargs -0 tag-command --flags
But that is wrong!
This is the way it should be:
find -name "*.mp3" -print0 |xargs -0 tag-command --flags
Thanks to jax for pointing this out.