Is there a way to read the mp3 tags of a file from the shell? Something like:
mp3tags MyFile.mp3 author
should output the author-tag of an mp3-file.
MP3 Tags Shell – How to Read MP3 Tags in Shell
command lineid3mp3tag
command lineid3mp3tag
Is there a way to read the mp3 tags of a file from the shell? Something like:
mp3tags MyFile.mp3 author
should output the author-tag of an mp3-file.
Best Answer
You can also use
ffprobe
which is part offfmpeg
.If you don't want other information, like track length and so on, you can combine the output with grep:
Or in order to get only the author:
You can select other tags by separating them with a comma, such as
format_tags=title,album
.I wanted to search for a keyword in all mp3 files in a folder. The folder had 486 files, so it became interesting to know which of the solutions mentioned here is the fastest. Here is the loop I used:
Notes:
lltag
andmp3info
don't find a title, because the files I was using had ID3v2 tags, see the comment by @s-prasanth: How to read mp3 tags in shell?eyeD3
is problematic to use programmatically, because it uses color codes (boldness).eyeD3
and alsoid3v2
(but only for ID3 v1 tags) return the title and the artist on the same line, which further complicates things; thereforegetTitleEyed
and sometimesgetTitleId3
return both the title and the artist, so please don't copy-paste those functions.getTitleId3 will only work for ID3 v2 tags, because
id3v2
has different formats for ID3v1- and ID3v2-tags, i.e.vs. ID3v2:
As the only program of these 5
eyeD3
prints a red warning for two of the files:It seems like those two files have ID3v1 tags, because those two files are the only ones where
lltag
andmp3info
can get a title. I'm wondering if this is a bug ineyeD3
as no other program mentioned here has a problem with these files ...Results (real time):
Time-wise the winner here is
id3tool
(mp3info is faster, but doesn't work with ID3 v2).id3v2
is also quite fast, but thegetTitleId3
function would need adjustment to also work with ID3v1-tags, which may at worst slow it down by factor 2.