The vorbistags program

From time to time, I make a list of the music on my file server: vorbiscomment extracts the names and titles, AWK puts them in a suitable format for sorting, sort sorts them, and another bit of AWK makes a nicely formatted list. But the list is quite long and the file server is a slow machine with little memory. So I was looking for a way to use fewer and smaller programs. Vorbistags replaces the first half of that pipeline.

Vorbistags prints the tags found in an Ogg Vorbis file and can also print some other information, such as file size and average bitrate. It is far from unique in that. But what I didn't find in any other such program is the possibility to format the output in different ways. An old program for MP3, mp3info, has that capability: a printf-like format string controls the output. Vorbistags is very similar to that.

Examples

Here are some examples of command lines. See the vorbistags man page for the full documentation.

Tab-separated output

A handy format for processing with Unix utilities such as sort and cut is the tab-separated format. The following prints the artist and title of each of the files given as arguments, one file per line, with a tab between the artist and the title:

vorbistags -f '%{ARTIST}\t%{TITLE}\n' *.ogg

There are one-letter abbreviations for the most common tags, and the above can also be written as:

vorbistags -f '%a\t%t\n' *.ogg

Info about the file and the encoding

The following prints four lines for each file: the file name, the file size, the average bit rate, and an empty line:

vorbistags -f 'file : %F\nsize : %k KB\nrate : %r kb/s\n\n' *.ogg

UTF-8 encoding

The comments in an Ogg Vorbis file are stored in UTF-8 encoding, and when vorbistags displays them on a system that uses a different encoding, some letters may be approximated or even omitted when they cannot be displayed. When the output isn't meant for display, but for further processing, it is better to output the raw text in UTF-8. This is done with the --raw (or -R) option:

vorbistags -R -f '%a\t%l\t%t\n' *.ogg >store-utf-8.txt

(Of course, if the terminal is configured to display UTF-8, the --raw option makes no difference.)

P.S. See also vorbiscommentedit, my wrapper around vorbiscomment, for easier editing of the tags in multiple Ogg Vorbis files at once.

P.P.S. There is now also flactags, the corresponding program for FLAC files.

Bert Bos
Created 28 February 2011