Added -T option for cdripper and tagfromfilename.
This commit is contained in:
@ -5,6 +5,7 @@
|
||||
# options:
|
||||
# -n: Only set the track number
|
||||
# -0: Leading 0s in track number are preserved
|
||||
# -T: Tag names (not tag content) written to the metadata in all caps
|
||||
#
|
||||
# Adds Vorbiscomment data to ogg vorbis and flac files based on the filename.
|
||||
# Files should be in Patrick's arbitrary file name standard, which is:
|
||||
@ -17,6 +18,7 @@
|
||||
# Requires vorbiscomment and metaflac
|
||||
#
|
||||
# Changelog:
|
||||
# 0.2.4: added -T option
|
||||
# 0.2.3: added documentation, -0 command-line option
|
||||
# 0.2.2: added flac support, documentation
|
||||
# 0.2.1: fixed version in help message
|
||||
@ -25,8 +27,8 @@
|
||||
# 0.1.1: added version variable
|
||||
# 0.1: initial implementation
|
||||
|
||||
$VERSION = "0.2.3";
|
||||
$HELP_MSG = "Vorbiscomment from Filename $VERSION\n\tusage: vcfromfilename [options] <files>\n\nValid options:\n\t-n\tOnly set the track numbers\n\t-0\tPreserve leading 0s in track numbers";
|
||||
$VERSION = "0.2.4";
|
||||
$HELP_MSG = "Vorbiscomment from Filename $VERSION\n\tusage: vcfromfilename [options] <files>\n\nValid options:\n\t-n\tOnly set the track numbers\n\t-0\tPreserve leading 0s in track numbers\n\t-T: Write tag names (not tag content) in all caps";
|
||||
|
||||
chomp($COMMENTFILENAME = '/tmp/vcfromfilename-' . `whoami`);
|
||||
|
||||
@ -34,14 +36,15 @@ chomp($COMMENTFILENAME = '/tmp/vcfromfilename-' . `whoami`);
|
||||
foreach (@ARGV)
|
||||
{
|
||||
if (/^(-h)|(--help)$/) { die $HELP_MSG; }
|
||||
if (/^-n$/) { $tracknumonly = true; s/.*//g; }
|
||||
if (/^-0$/) { $extrazero = true; s/.*//g; }
|
||||
elsif (/^-n$/) { $tracknumonly = true; s/.*//g; }
|
||||
elsif (/^-T$/) { $captagnames = true; s/.*//g; }
|
||||
elsif (/^-0$/) { $extrazero = true; s/.*//g; }
|
||||
}
|
||||
|
||||
# Set the album name
|
||||
$album = `pwd`; # We WANT the newline here
|
||||
$album =~ s/^.*\///; # Remove everything up to the last /
|
||||
$album = formatName($album, 'album=');
|
||||
$album = formatName($album, 'album=', $captagnames);
|
||||
|
||||
# Parse the file list, set vorbiscomments
|
||||
foreach (@ARGV)
|
||||
@ -79,13 +82,13 @@ foreach (@ARGV)
|
||||
# Add the artist
|
||||
my $artist = $_;
|
||||
$artist =~ s/^(.*?)-\d{2}-.*/\1/; # grab everything to the track number
|
||||
$artist = formatName($artist, 'artist=');
|
||||
$artist = formatName($artist, 'artist=', $captagnames);
|
||||
print COMMENTFILE $artist;
|
||||
|
||||
# Add the title
|
||||
my $title = $_;
|
||||
$title =~ s/.*-\d{2}-(.*)\.(ogg|flac)$/\1/; # grab everything after the track number
|
||||
$title = formatName($title, 'title=');
|
||||
$title = formatName($title, 'title=', $captagnames);
|
||||
print COMMENTFILE $title;
|
||||
|
||||
# And the album
|
||||
@ -96,7 +99,7 @@ foreach (@ARGV)
|
||||
my $tracknum = $_;
|
||||
$tracknum =~ s/.*-(\d{2})-.*/\1/;
|
||||
if (!$extrazeros) { $tracknum =~ s/\b0*//; } # removing leading zeros
|
||||
$tracknum = formatName($tracknum, 'tracknumber=');
|
||||
$tracknum = formatName($tracknum, 'tracknumber=', $captagnames);
|
||||
print COMMENTFILE $tracknum;
|
||||
|
||||
close COMMENTFILE;
|
||||
@ -107,10 +110,14 @@ foreach (@ARGV)
|
||||
}
|
||||
|
||||
# Formats the first argument, adds the second argument to it
|
||||
# If the third argument is true, the second argument is converted
|
||||
# to upper case
|
||||
sub formatName
|
||||
{
|
||||
my $name = shift;
|
||||
my $prepend = shift;
|
||||
my $upper = shift;
|
||||
if ($upper) { $prepend = uc($prepend); }
|
||||
chomp $name; # we add a newline ourselves
|
||||
$name =~ s/_/ /g; # underscore - space
|
||||
$name =~ s/^\s*//; # Remove leading space
|
||||
|
Reference in New Issue
Block a user