From 5dddb1f08e099451440b680c2df271c5de375e90 Mon Sep 17 00:00:00 2001 From: Anna Wiggins Date: Thu, 26 Mar 2009 09:45:25 -0400 Subject: [PATCH] Added support for keeping leading 0s in metadata --- tagfromfilename | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/tagfromfilename b/tagfromfilename index 8873810..d602b02 100755 --- a/tagfromfilename +++ b/tagfromfilename @@ -4,23 +4,29 @@ # usage: vcfromfilename [options] # options: # -n: Only set the track number +# -0: Leading 0s in track number are preserved # # Adds Vorbiscomment data to ogg vorbis and flac files based on the filename. -# Files should be in darkside's arbitrary file name standard, which is: -# album/artist-tracknum-title.(ogg|flac) +# Files should be in Patrick's arbitrary file name standard, which is: +# artist/album/artist-tracknum-title.(ogg|flac) +# +# The top-level directory (artist) is optional. Filenames should contain no +# spaces; underscores in the filename are converted to spaces in the resulting +# metadata # # Requires vorbiscomment and metaflac # # Changelog: -# 0.2.2: added flac support +# 0.2.3: added documentation, -0 command-line option +# 0.2.2: added flac support, documentation # 0.2.1: fixed version in help message # fixed handling of dashes in artist name and title # 0.2: aligned version with ds-audiotools # 0.1.1: added version variable # 0.1: initial implementation -$VERSION = "0.2.2"; -$HELP_MSG = "Vorbiscomment from Filename $VERSION\n\tusage: vcfromfilename [options] \n"; +$VERSION = "0.2.3"; +$HELP_MSG = "Vorbiscomment from Filename $VERSION\n\tusage: vcfromfilename [options] \n\nValid options:\n\t-n\tOnly set the track numbers\n\t-0\tPreserve leading 0s in track numbers"; chomp($COMMENTFILENAME = '/tmp/vcfromfilename-' . `whoami`); @@ -29,6 +35,7 @@ foreach (@ARGV) { if (/^(-h)|(--help)$/) { die $HELP_MSG; } if (/^-n$/) { $tracknumonly = true; s/.*//g; } + if (/^-0$/) { $extrazero = true; s/.*//g; } } # Set the album name @@ -88,7 +95,7 @@ foreach (@ARGV) # Now get the track number my $tracknum = $_; $tracknum =~ s/.*-(\d{2})-.*/\1/; - $tracknum =~ s/\b0*//; # removing leading zeros + if (!$extrazeros) { $tracknum =~ s/\b0*//; } # removing leading zeros $tracknum = formatName($tracknum, 'tracknumber='); print COMMENTFILE $tracknum;