The flactags program

The flactags program displays some of the information contained in a FLAC file, such as the embedded comments (ARTIST, TITLE, etc.), length in seconds and bitrate. That information can also be extracted by using the metaflac program, but the advantage of flactags is that it gives control over the output by means of a printf-like format string.

The program is a companion to vorbistags, which does the same thing with Ogg Vorbis files. Both flactags and vorbistags were inspired by mp3info (by Cedric Tefft).

Flactags reads, but doesn't change FLAC files. To alter the embedded comments in a FLAC file, you might be interested in my vorbiscommentedit program.

Examples

Here are some example command lines. See the flactags manual for the full documentation.

CSV output

The following creates a CSV (Comma-Separated Values) file with three columns: the file name of a FLAC file, the artist of that file and the song title:

flactags -e2 -f '"%f","%a","%t"\n" *.flac >myfiles.csv

The string after -f is the format string. The format is used once for each input file. The %f, %a and %t are variables that will be replaced by the file name, the artist and the title, resp. of each FLAC file. The \n stands for a newline. The other characters (" and ,) are copied to the output as they are.

The -e2 option makes sure that any double quotes in the replaced variables are properly doubled, as required for CSV files. It also replaces any line breaks in the replaced variables by the two characters \n, so that the output is on a single line.

The result might look like this:

"dooby.flac","Mike ""Duckman"" Witts","Dooby"
"elf.flac","The Players","What the elf?"
"wahwah.flac","Joe Singer","Wah wah"

Here is the same example, but using long variable names for the comments. Long names are enclosed in %{…} like this:

flactags -e2 -f '"%f","%{ARTIST}","%{TITLE}"\n" *.flac

TSV output

The following example outputs the same information, but as a TSV (Tab-Separated Values) file:

flactags -e1 -f '%f\t%a\t%t\n" *.flac >myfiles.tsv

TSV files don't have quotes around the values and use tab characters instead of commas between them. An easy way to include a tab character in a format string is to use the two-character sequence \t.

The option -e1 causes any tabs in the replaced variables to be replaced by \t, so they cannot be misinterpreted as field separators. It also escapes newlines in the variables as \n.

The result might look like this:

dooby.flac	Mike "Duckman" Witts	Dooby
elf.flac	The Players	What the elf?
wahwah.flac	Joe Singer	Wah wah
Bert Bos
Created 25 May 2016