Linux – Command line tool for listing ID3 tags under Linux

command lineid3linux

I want to write a script that manipulates ID3 tags of mp3 files. I need a tool that reads the tags and outputs it in a format in a machine-readable format. For example, if I want it to output only the title, then it outputs the title, nothing else. I tried different tools like id3 or eyeD3, but they can only be used to write tags or to output them in a human-readable format. Of course I could just filter that output through sed, but it seems unnecessarily complicated to me.

Best Answer

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)"
}]
Related Question