Command line tool for listing ID3 tags under Linux

Solution 1:

You could use the exiftool command from the libimage-exiftool-perl package which lets you read (and write) metadata from multimedia files, including mp3s. It can output to a variety of formats including key-value, json, xml and user-defined formats. You can choose to list only specified tags.

% exiftool -json 09\ -\ \(Tom\ Waits\)\ -\ Walk\ Away.mp3
[{
  "SourceFile": "09 - (Tom Waits) - Walk Away.mp3",
  "ExifToolVersion": 7.82,
  "FileName": "09 - (Tom Waits) - Walk Away.mp3",
  "Directory": ".",
  "FileSize": "2.5 MB",
  "FileModifyDate": "2008:07:12 13:58:52+01:00",
  "FileType": "MP3",
  "MIMEType": "audio/mpeg",
  "MPEGAudioVersion": 1,
  "AudioLayer": 3,
  "AudioBitrate": 128000,
  "SampleRate": 44100,
  "ChannelMode": "Stereo",
  "MSStereo": "Off",
  "IntensityStereo": "Off",
  "Emphasis": "None",
  "ID3Size": 1678,
  "Title": "Walk Away",
  "Album": "Dead Man Walking",
  "Genre": "OST",
  "Track": 9,
  "Artist": "Tom Waits",
  "Year": "",
  "Comment": "",
  "Duration": "02:42 (approx)"
}]

Solution 2:

id3info in id3lib outputs the ID3 tags in a format that's dead simple to machine-parse.

Solution 3:

I would look into the Mutagen tagging library for Python, which includes a basic scriptable command-line tool, mid3v2. While mid3v2's output is primarily human-readable, the --list-raw option may be suitable by itself:

$ mid3v2 --list-raw 09_Walk\ Away.mp3
Raw IDv2 tag info for 09_Walk Away.mp3:
TDRC(encoding=3, text=[u'1996'])
TIT2(encoding=3, text=[u'Walk Away'])
TRCK(encoding=3, text=[u'9'])
TPE1(encoding=3, text=[u'Tom Waits'])
TALB(encoding=3, text=[u'Dead Man Walking'])
TCON(encoding=3, text=[u'Soundtrack'])

Note this tool only lists ID3 tags, not additional attributes of the MP3 file like exiftool. But if you wanted only a particular tag, a simple grep for the tagname will grab that for you:

$ mid3v2 --list-raw 09_Walk\ Away.mp3 | grep TIT2
TIT2(encoding=3, text=[u'Walk Away'])

If mid3v2 isn't enough for you by itself, and you're comfortable with Python, you could script your own tool to interface with the Mutagen library and read or manipulate the tags directly.