Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Perl Regular Expression [ID3] Tag [Tool]
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
README
pretag

README

PRETag (or Perl Regular Expression [ID3] Tag [Tool]) allows you to tag your MP3
files using Perl regular expressions. Who would have thought! Run with -h for
all the information you need, including examples.

For your convencience, I've pasted the output of pretag -h here so you don't
have to install it to see if it is what you're looking for.

------------------------------------------------------------------------------

Usage: /home/jkramer/scripts/pretag <-p pattern> [optional stuff] [bunch of MP3 files]

-p <pattern> | --pattern=<pattern>
Looking at the usage line above, you might have thought, "hey, -p is the
only non-optional argument, so it must be important," and you're right!
This whole script is about that pattern, because it lets us gather track
information from file names using a regular expression. This is why you
need to know (Perl) regular expressions to use this tool. The wanted
information is extracted from the file names using "named groups" or "named
capture buffers". Check perlre(1pm) and the examples below for details.

-v | --verbose
Print lots of information about what's going on.

-h | --help
Print this help text and quit.

-d | --dry-run
Don't actually do anything (only useful with -v to see what would be done
if you had not used -d).

-c | --title-case
Try to fix the title case of found tags.

-N <noise> | --noise=<noise>
Use this to define a regular expression that matches characters and strings
considered line noise. E.g., some people think it's funny to distribute
files like this "09-bloodhound_gang_-_the_ballad_of_chasey_lain-ysp.mp3"; use
"-N '_|-ysp'" to fix it.

-z <width> | --zero-pad=<width>
Use this to fill the track number with zeros to the given width. For
example, the original track number 1 would become 001 with -z 3. Only
affects the generated file name (when -r is given), not the ID3 tag.

-r <format> | --rename=<format>
Rename the file using the given file name format. The format should like this:
"<track> - <artist> - <title>.mp3" - guess I see the pattern. Just put any of
the long tag option names between <> and it will be replaced with the
corresponding tag data.

-u | --update
Update the MP3 files ID3 tags with the information captured from the file
name and/or defined as command line argument.

Note: Even if you have specified a tag in your regular expression, if you
also define the tag using one of the options below, it will override the
one found in the file name.

-a <artist> | --artist=<artist>
Override artist.

-l <album> | --album=<album>
Override album.

-t <title> | --title=<title>
Override title (sometimes called song name).

-n <track-number> | --track=<track-number>
Override track number.

-y <year> | --year=<year>
Override release year.

-o <comment> | --comment=<comment>
Override comment.

-g <genre> | --genre=<genre>
Override genre


Examples

Assuming you pirated the album "Back on the Streets" by 88 Fingers Louie
somehow (don't do that, it's illegal!), but the ID3 tags are in bad shape and
you don't like the file names because they look like this:

[01] - 88 fingers louie - tomorrow starts today.mp3
[02] - 88 fingers louie - selfish means.mp3
...

Then you might try this.

/home/jkramer/scripts/pretag 
	-p '^\[(?<track>\d+)\] - (?<artist>.*?) - (?<title>.*)\.mp3$' 
	-l 'Back on the Streets' 
	-c -u -y 1998 -g 'Hardcore' 
	*.mp3

Adding -v, the script would print something like this:

[01] - 88 fingers louie - tomorrow starts today.mp3:
		Artist: 88 Fingers Louie
		Album:  Back on the Streets
		Title:  Tomorrow Starts Today
		Track:  01
		Year:   1998
		Genre:  Hardcore
		Comment:
Writing tags for [01] - 88 fingers louie - tomorrow starts today.mp3.
...

Use -r to rename files using the freshly detected meta data.

For example, add this to the command above:

... -z 2 -r '<track> - <title>.mp3'

This will rename the file in the example above from '[01] - 88 fingers louie -
tomorrow starts today.mp3' to '01 - Tomorrow Starts Today.mp3'.

Something went wrong with that request. Please try again.