我正在寻找一种方法,可以让我从 mp3 文件的 ID3 标签中获取特定字段。
到目前为止,我发现的所有工具都会返回所有字段,并且它们还会对它们进行格式化以“更容易阅读”。我只需要一些字段,并且格式不同(艺术家\talbum\ttitle\n)用于报告目的。
有没有这样的工具?我喜欢可以让我从 ID3v1 和 ID3v2 分别输出值的工具。
id3v2 -R
听起来像你想要的。Debian 包名是 id3v2,上游是http://id3v2.sourceforge.net/
从手册页:
-R, --list-rfc822
Lists using an rfc822-style format for output
例子:
$ id3v2 -R 365-Days-Project-04-26-sprinkle-leland-w-the-great-stalacpipe-organ.mp3
Filename: 365-Days-Project-04-26-sprinkle-leland-w-the-great-stalacpipe-organ.mp3
TALB: Released independently through Luray Caverns
TPE1: Leland W. Sprinkle
TIT2: The Great Stalacpipe Organ
COMM: ()[eng]: � 2004, Copyright resides with the artist, The 365 Days Project, and UbuWeb (http://ubu.com) / PennSound (http://www.writing.upenn.edu/pennsound/). All materials at UbuWeb / PennSound are available for free exchange for noncommerical purposes.
365-Days-Project-04-26-sprinkle-leland-w-the-great-stalacpipe-organ.mp3: No ID3v1 tag
最简单的方法是创建一个 bash 脚本。
grep
您的工具返回的字段,以便您获得所需的字段。然后你使用awk
(如果你知道如何使用它),或者cut
,等等。
如果您向我们提供您找到的工具之一使用的格式,我们可以帮助您编写它。格式越简单,脚本就越简单。