From e2f76a22f65c237c91baadca82babba765e0c5a3 Mon Sep 17 00:00:00 2001 From: Anna Wiggins Date: Thu, 25 Mar 2010 14:58:39 -0400 Subject: [PATCH] Use year tag instead of releasedate --- tagfromfilename | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tagfromfilename b/tagfromfilename index 34a4d33..49eb969 100755 --- a/tagfromfilename +++ b/tagfromfilename @@ -52,7 +52,7 @@ $album = formatName($album, 'album=', $captagnames); # Get the release date, just use the first track -my $releasedate = 'releasedate='; +my $year; # Parse the file list, set vorbiscomments @@ -73,8 +73,8 @@ foreach (@ARGV) system("metaflac --remove-tag=tracknumber $_"); if (!$tracknumonly) { - system("metaflac --remove-tag=TITLE --remove-tag=ARTIST --remove-tag=ALBUM --remove-tag=RELEASEDATE $_"); - system("metaflac --remove-tag=title --remove-tag=artist --remove-tag=album --remove-tag=releasedate $_"); + system("metaflac --remove-tag=TITLE --remove-tag=ARTIST --remove-tag=ALBUM --remove-tag=YEAR $_"); + system("metaflac --remove-tag=title --remove-tag=artist --remove-tag=album --remove-tag=year $_"); } } # Preserve existing comments, except the ones we'll replace @@ -83,7 +83,7 @@ foreach (@ARGV) foreach (`vorbiscomment -l $_`) { if ($tracknumonly) { print COMMENTFILE $_ unless (/^tracknumber/i); } - else { print COMMENTFILE $_ unless (/^(title)|(artist)|(tracknumber)|(album)|(releasedate)/i); } + else { print COMMENTFILE $_ unless (/^(title)|(artist)|(tracknumber)|(album)|(year)/i); } } } @@ -121,7 +121,7 @@ foreach (@ARGV) # Finally, try to find the release date, if we haven't yet - if ($releasedate =~ /^releasedate=\s*$/) + if (!$year) { my $mbinfo = Music::Tag->new($_); @@ -130,12 +130,12 @@ foreach (@ARGV) $mbinfo->add_plugin("MusicBrainz"); $mbinfo->get_tag(); - $releasedate = formatName($mbinfo->releasedate, 'releasedate=', $captagnames); + $year = formatName($mbinfo->year, 'year=', $captagnames); } } -if ($tracknumonly || $releasedate =~ /^releasedate=\s*$/) { exit; } +if ($tracknumonly || $year =~ /^year=\s*$/) { exit; } # Loop back through the files again, adding the release date @@ -150,11 +150,11 @@ foreach(@ARGV) { foreach (`vorbiscomment -l $_`) { - print COMMENTFILE $_ unless (/^releasedate/i); + print COMMENTFILE $_ unless (/^year/i); } } - print COMMENTFILE $releasedate; + print COMMENTFILE $year; close COMMENTFILE; if ($isflac) { system("metaflac --import-tags-from=$COMMENTFILENAME $_"); }