Hund

How to edit your music data tags using the command-line

August 6, 2020

The command-line tool Audiotag is an easy to use Perl-script for editing the data tags in your music files. It supports the formats MP3, OGG Vorbis, MP4, M4A and FLAC.

Example usage

To print information about a track you use the flag -l, --list-info:

$ audiotag -l 01_Claustrophobic_Amnesia.ogg

*** `01_Claustrophobic_Amnesia.ogg'
=== ALBUM: TENONDERGANG
=== ALBUMARTIST: Ter Ziele
=== ARTIST: Ter Ziele
=== COMMENT: Visit http://terziele.bandcamp.com
=== DATE: 2018
=== TITLE: Claustrophobic Amnesia
=== TRACKNUM: 1
=== TRACKNUMBER: 1

I noticed that the track is missing a genre, let’s set the genre for all the tracks of that album:

$ audiotag -g "Depressive suicidal black metal" *.ogg

It’s simple as that. To list all available features just use the flag -h, --help. I also highly recommend using the flag -p, --pretend to dry run the command if you’re not 100% sure about what you’re about to do.

Installation

The easiest option is probably to clone the Git-repository on GitHub and copy the script to your $PATH. Just make sure that you have installed Perl (version 5.6 or newer) and:

  • For MP3-support: id3tag or id3lib.
  • For OGG Vorbis-support: vorbiscomment from vorbis-tools.
  • For FLAC-support: metaflac from flac.

If you’re using Gentoo, these are packages you might be looking for:

  • MP3: media-libs/id3lib
  • OGG Vorbis: media-sound/vorbis-tools
  • FLAC: media-libs/flac
  • MP4/M4A: media-video/atomicparsley

If you don’t have support for a format it might annoyingly remind you about it every time you use the tool:

$ audiotag -h                                                                                           -- INSERT --
WARNING: `AtomicParsley' not found in path, required for mp4 support!
WARNING: `AtomicParsley' not found in path, required for m4a support!
[...]

As you can see I don’t have support for MP4 or M4A and I don’t care. I fixed this issue by commenting out two parts of the script between the lines 473-491:

# MCM - handle mp4 and m4a using AtomicParsley
elsif ($file =~ /\.mp4$/i or $file =~ /\.m4a$/i) {
	push @cmd, "AtomicParsley";
	push @cmd, $file;
	foreach (sort { $a cmp $b } keys %$info) {
		# don't need extra track num field
		/TRACKNUMBER/ && next;
		$plus_tags{$_} ||= "===";
		push @result, "$plus_tags{$_} $_: $info->{$_}";
	}
	if ($genre   ) { push @cmd, ("--genre", uc $genre);		}
	if ($artist  ) { push @cmd, ("--artist", $artist);		}
	if ($album   ) { push @cmd, ("--album", $album);		}
	if ($title   ) { push @cmd, ("--title", $title);		}
	if ($track   ) { push @cmd, ("--track", $track);		}
	if ($year    ) { push @cmd, ("--year", $year);			}
	if ($comments) { push @cmd, ("--comment", $comments);	}
	push @cmd, ("--overWrite", "--gapless", "true");
}

And the lines 663-664:

check_for_prog(\@filetypes, \@missing, "mp4", "AtomicParsley"     );
check_for_prog(\@filetypes, \@missing, "m4a", "AtomicParsley"     );

It then stopped complaining about it.

Meta

No Comments

Use the e-mail form, if you wish to leave feedback for this post. Markdown is supported. [Terms of service]