Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

Anyone know of a command-line* ID3 tool, with support for ID3v2, that you can get working on Mac OS X with reasonable effort? It should support both reading and writing tags.

(* I want to be able to call it e.g. from some Python scripts, so a GUI tool won't do.)

The id3tool utility is otherwise good, but doesn't support ID3v2 (and thus doesn't play that well with iTunes). I had to compile it from source, but that was pretty straightforward on a Mac with Xcode & developer tools (including, notably, a C compiler). Anyway, I'd especially like something with similar command-line options as id3tool. Here's an example of tagging one file:

id3tool -t "Song Title" -r Artist -a "Album Name" -c 2 track-02.mp3
share|improve this question
    
i've been working on writing something like this... there are some libraries available in python and there is a tool called beets that makes use of them so i've been investigating how it's written. –  Robert S Ciaccio Nov 1 '10 at 1:59
1  
in addition... MusicBrainz Picard is written in Python and is open source so there's probably a lot to be gleaned from it's code and library usage as well. –  Robert S Ciaccio Nov 1 '10 at 5:52
    
i agree, Picard is just brilliant –  bronzebeard Nov 13 '10 at 9:51
add comment

9 Answers

up vote 11 down vote accepted

There's an OS X compatible version of the id3lib library available here on GitHub. It claims to support both ID3v1 and ID3v2.

share|improve this answer
    
Thanks! This fully answers my question. There was only source package available, but installing from that (on a Mac with developer tools) was pretty smooth: the standard Unix fare of configure, make and make install. id3lib consists of 4 separate binaries: id3info (for reading tags), id3tag (for writing tags), id3convert, and id3cp. Everything works fine (and iTunes honours the v2 tags written with id3tag). –  Jonik Nov 13 '10 at 11:39
    
@Jonik what did you use to wrap the library? Some python you wrote? –  Robert S Ciaccio Nov 15 '10 at 5:50
    
@calavera: Yeah, I have simple scripts that try to determine track number or name from a filename (such as "Artist - 03 - Track.mp3"), and if found, write it to ID3 tag too. –  Jonik Nov 15 '10 at 6:37
    
@Jonk: would you be willing to share? I don't have a lot of experience with python so something like that would be great to play around with and extend... –  Robert S Ciaccio Nov 15 '10 at 16:01
    
@calavera: Here you go. Usage: add-track-names.py *mp3 or add-track-numbers.py *mp3. Common stuff (most code) is in a separate .py file. I'm not really a Python coder either, so the code's probably far from "pythonic". :) But I (re)learned a lot when I wrote it, and it's probably easy to extend if your tagging needs are anything like mine. –  Jonik Nov 15 '10 at 20:08
show 1 more comment

Having had various 'abort trap' type issues with id3v2 I discovered eyeD3, which is a python module also existing as a command line tool. It seems to be more recently updated than some of the other programs mentioned above.

share|improve this answer
add comment

You may want to try id3v2. It's based on the id3lib that Huyz mentioned, but seems to be a better command line tool than those with id3lib. It easily dumps the ID3V2 tags from iTunes produced MP3s, but not iTunes produced M4A files (as with Apple Lossless).

If you need M4A files, another option is ffmpeg. Its ffprobe command line tool prints out metadata in the files and I believe you can write metadata via ffmpeg. It works with both MP3 and M4A files produced by iTunes. ffprobe may not show all metadata; mp4v2 is another good option.

All three programs are easily installed via Homebrew. Right now (Jan 2012) ffmpeg requires gcc to compile, so brew install --use-gcc ffmpeg.

share|improve this answer
    
id3v2 -t ö test.mp3 results in mojibake like with id3tag. mid3v2 also works with Unicode characters. –  Lauri Ranta Aug 12 '12 at 17:01
add comment

If you have Homebrew installed (highly recommended), you can just do:

brew install id3lib

This installs several id3 command-line tools, including id3tag. No need for python or perl scripting; just use regular shell commands.

Usage: id3tag [OPTIONS]... [FILES]...
   -h         --help            Print help and exit
   -V         --version         Print version and exit
   -1         --v1tag           Render only the id3v1 tag (default=off)
   -2         --v2tag           Render only the id3v2 tag (default=off)
   -aSTRING   --artist=STRING   Set the artist information
   -ASTRING   --album=STRING    Set the album title information
   -sSTRING   --song=STRING     Set the title information
   -cSTRING   --comment=STRING  Set the comment information
   -CSTRING   --desc=STRING     Set the comment description
   -ySTRING   --year=STRING     Set the year
   -tSTRING   --track=STRING    Set the track number
   -TSTRING   --total=STRING    Set the total number of tracks
   -gSHORT    --genre=SHORT     Set the genre
   -w         --warning         Turn on warnings (for debugging) (default=off)
   -n         --notice          Turn on notices (for debugging) (default=off)
share|improve this answer
    
Does it support ID3v2? –  Jonik Jun 19 '11 at 2:37
    
id3lib also works in other distributions such as macports. Speaking of, is there any point in switching from ports to homebrew? I had so much pain switching from fink... –  HiQ CJ Jul 19 '11 at 12:12
    
id3tag -s ö test.mp3 seems to currently result in mojibake. mid3v2 also supports Unicode characters. –  Lauri Ranta Aug 12 '12 at 17:07
    
"Error: No available formula for mid3v2". Somebody interested in contributing a formula? –  ManuelSchneid3r Feb 13 at 12:58
add comment

The python module Mutagen is shipped with the command-line ID3 tool named mid3v2 replacement for id3lib's.
From the usage documentation :

You can set the value for any ID3v2 frame by using '--' and then a frame ID.
For example:
mid3v2 --TIT3 "Monkey!" file.mp3 would set the "Subtitle/Description" frame to "Monkey!".

share|improve this answer
    
Mutagen can be installed with sudo pip install mutagen after installing pip with sudo easy_install pip. –  Lauri Ranta Aug 12 '12 at 17:04
add comment

since you're comfortable with cli and Python, I can recommend some Perl modules on CPAN. MP3::Tag, (as well as MP3::Tag::ID3v1 and ::ID3v2 and ::Utils), MP3::Info, MP3::ID3Lib are all available for reading and manipulating ID3 tags.

If you go to search.cpan.org and search for "MP3", you'll find a world* of options!

(* Where "world" is a small, limited set of options...)

share|improve this answer
    
CLI and Python yes, but Perl modules on CPAN... not so much :-) (If you can use those in Python too, I wasn't aware of that. Or did you mean writing Perl instead?) Personally I got this solved already, but maybe this is helpful for others. –  Jonik Nov 15 '10 at 14:21
add comment

This site: http://dougscripts.com/itunes/ has many good command line scripts and tools that layer on top of itunes to do things with your music library. Some of them may do what you want. Some of the tools are free and some are licensed.

share|improve this answer
add comment

There is always AppleScript. I'm not a big fan of it, but iTunes is scriptable and you can manipulate all the mp3 tags from there. You can invoke Applescript from the command line using osascript.

share|improve this answer
add comment

This old thread at Mac OS X Hints looks like it might be a good place for you to start. It's from 2003, so I'm not sure if the tool they're talking about is still being developed. You also may have to compile it yourself.

share|improve this answer
add comment

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.