I've managed a work around, albeit via a PHP script, since the end goal was to bring the tags into a database served up by a web server. First, list all flac files to a text file:
find /media/marcel/Archives2/Albums -type f -name '*flac' > flac_files.txt
Using PHP, open the file for read, then get a database handle and prepare a PDO statement to write each filename:
$dbh = new PDO(<database_details>, <user>, <pw>, <persistent>);
$qry = "INSERT INTO temp (filename) VALUES (?)";
$stmt = $dbh->prepare($qry);
$flac = fopen('/media/marcel/Archives2/Albums/flac_files.txt', "r");
Now parse through each line in flac_files.txt, write the filename to the database using the prepared query, get the tag values into an array from a metaflac shell and write each in turn to the database:
while (!feof($flac)) {
$filename = rtrim(fgets($flac));
$stmt = $dbh->bindParam(1, $filename);
$stmt->execute();
$tag_list = explode("\n", shell_exec('metaflac --export-tags-to=- "' . $filename . '"')) //explode on linefeed character;
$c = count($tag_list);
for ($i = 0 ; $i < $c ; $i++) {
$tag = explode('=', $tag_list[$i]);
if ($tag[0]) { // no empty tags!
$rec = "UPDATE albums.temp SET " . $tag[0] . " = '" . str_replace("'", "’", $tag[1]) . "' WHERE filename = '" . $filename . "'"; //no quotes, just real apostrophes
$data = $dbh->query($rec);
}
}
}
Quick & dirty, but works. Of course you will need to set up the temp table with the appropriate tags as column names in advance. Alternatively, you could write each filename out to a second file, followed by the tags retrieved from a metaflac command, then finish up each one with a delimiter, say "@" on its own line. Also tedious, but also works.