Making multiple words into one TAG (Filename-Tag)


#1

QUESTION 1 - How can I condense multiple words into ONE tag when there's no special character identifying the end of the desired tag?

===========
EXAMPLE

FILENAME:
Tom Clancy - Eaters of the Dead D03_01.mp3

Convert/FILENAME-TAG
Tom Clancy - Eaters of the Dead D03_01.mp3
FORMAT STRING:
%artist% - %title% %discno%_%trackno%

RESULT
Artist: Tom Clancy
Title: Eaters
DiscNo: of the Dead D03
TrackNo: 01

We can tell MP3Tag how many digits to use when writing numbers - $num(%field%,2) - but is there a way to tell Mp3Tag to grab the next "x" number of WORDS when creating a TAG from a FILENAME?

$word(%title%,4)

=====================
QUESTION #2 - Removing the letter "D" from %discno%

Using the same example, how can I get the "D" to be removed from D03_01?
%discno%_%trackno% results in
DiscNo: D03
TrackNo: 01

when what I want is
DiscNo: 03
TrackNo: 01

Thanks so much.


#2

Use these actions for question 1:

Action #1:
Action type: Guess values
Source format: %_filename%
Guessing pattern: %artist% - %title%

Action #2:
Action type: Format value
Field: DISCNUMBER
Formatstring: $mid(%_filename%,$sub($len(%_filename%),4),2)

Action #3:
Action type: Format value
Field: TRACK
Formatstring: $mid(%_filename%,$sub($len(%_filename%),1),2)

Action #4:
Action type: Replace with regular expression
Field: TITLE
Regular expression: D\d{2}_\d{2}$
Replace matches with:

[ ] case-sensitive comparison

#3

Sebastian - Thanks so much for your help. Unfortunately, I can't get it to work due to my (obviously) being one of the non-binaries. I really do appreciate your help and have explained here what I did, what happened, and finished with begging you for help in determining where I'm going wrong in trying to decipher exactly what the $mid... formatstring is supposed to do. I realize this is well beyond the call of duty, but I thought I'd throw it out there. I completely understand if you can't, or don't want to answer. I can hire a tutor - it's not your job to lead the blind.

After I spent HOURS getting all these colors in this post (yours was SOOO easy to read!!) I think I may have hit upon a reason it's messing up, but I had to give up because at a glance, it doesn't look like my discovery would explain why I'm getting the result TRACK = f. There's no "f" in "Lie Down With Lions" so I'm lost.

I can work on it, and this is probably terrible, horrible no-good protocol, but I just spent so much time creating this post, I'm going to go ahead and run it away, hoping that you, or someone, can enlighten me on where I'm going wrong.

EXAMPLE
FILENAME: Ken Follett-Lie Down With Lions 01 of 20.mp3
TRACK: 1 (For some reason, the TRACK tag for each of the 20 files is shown as "1")

FIRST ACTION
Action type: Guess values
Source format: %_filename%
Guessing pattern: %artist% - %title%

RESULT
Artist: Ken Follett
Title: Lie Down With Lions 01 of 20. (<-period is included)

==========
QUESTION

Wouldn't the following achieve the same result without the period at the end?
Action type: Format value
Field: FILENAME
String: %artist%-%title%

================
SECOND ACTION
Action type: Format value
Field: DISCNUMBER
Formatstring: $mid(%_filename%,$sub($len(%_filename%),4),2)

RESULT
Artist: Ken Follett
Title: Lie Down With Lions 01 of 20. (<-period is still included)
Discnumber: f (Should be "01")

==================
So it's the $mid... formatstring that's messing up, right? I'm trying to understand exactly WHAT it does, so could you please look at my logic (below) and tell me just how clueless I am?

==============
WHAT I THINK HAPPENS IN $mid(%_filename%,$sub($len(%_filename%),4),2)

$len(%_filename%) - Returns the LENGTH of the FILENAME [Ooh ... I'm just proofing my post, and I'll bet the problem is that %_filename% should be %_title% !!]
QUESTION: Does $len use characters (space, hyphen) to count LENGTH? If so, $len(%_title%) would be returned as 7.

$sub((7),4) - SUBTRACTS 4 from 7 - resulting in 3

$mid(Lie Down With Lions 01 of 20,3,2)

Mp3Tag describes the $mid formatstring as follows:
$mid(x,n,i) - First i characters of text x, starting at character n.

I interpret this to be
i = 2
x = Lie Down With Lions 01 of 20
n = 3

which I interpret as
The first 2 characters of Lie Down With Lions 01 of 20, starting at character 3.

Which would be Li in "Lions", but my return is a lower-case f and nothing else.


#4

Sebastian made you an example for the filename Tom Clancy - Eaters of the Dead D03_01.mp3

Now you suddenly have the filename Ken Follett-Lie Down With Lions 01 of 20.mp3 that really has a different structure - it cannot work :rolleyes:

So if you want to understand the stuff you must exercise it on the first filename or else you will end up very confused (as you did :wink: )

So here's $mid(%_filename%,$sub($len(%_filename%),4),2) applied to the first filename:

%_filename% -> Tom Clancy - Eaters of the Dead D03_01
$len(%_filename%) -> 38
$sub($len(%_filename%),4) -> 34

That makes:
$mid(%_filename%,34,2) -> From Tom Clancy - Eaters of the Dead D03_01 go to position 34 and return the next 2 characters

Result: 03


#5

DANO:

OMG ... you are RIGHT! What was I thinking???? I can't believe that I didn't even THINK of that ... all I saw was that there was no SEPARATOR between the TITLE and the TRACK and throughout all the hours I spent trying to figure it out, the fact that there were two different TITLES never entered my mind. I can only offer the explanation that I was so intent upon figuring out the formatstrings and sub-structures that I had blinders on and thought of nothing else than $mid, $sub and $len.

I'm so sorry. I feel like such a fool, which, of course, is exactly what I am. Maybe I can blame it on being old, which I also am.

Thanks for your kindness in responding though. I'll work on it, but after the disastrous results of my earlier attempt, I think it's best that I take a break from it right now.


#6

I'll give you an easier approach:

It's easier to rename the filename first a little bit so you have a clear seperation between title and track-/discnumber
So this 2 actions will just insert a hyphen so you can use the convert tool without problems

Ken Follett-Lie Down With Lions 01 of 20.mp3
becomes
Ken Follett-Lie Down With Lions-01 of 20.mp3
Convert format string

%artist%-%title%-%track% of %discnumber%

Tom Clancy - Eaters of the Dead D03_01.mp3
becomes
Tom Clancy - Eaters of the Dead-D03_01.mp3
Convert format string

%artist% - %title%-D%discnumber%_%track%

Action #1:
Action type: Replace with regular expressions
Field: _FILENAME
Regular expression: \s+(\d\d\s+of\s+\d\d.mp3)$
Replace matches with: -$1

[ ] case-sensitive comparison

Action #2:
Action type: Replace with regular expressions
Field: FILENAME
Regular expression: \s+(D\d\d\d\d.mp3)$
Replace matches with: -$1

[ ] case-sensitive comparison

You can also download the actions to save the typing. The action includes everything, not only the file renaming.
The .bat file will open the right folder where you need to put the .mta file.

BTW there's a tool from Sebastian to show the actions as we did:
/t/2584/1

kcnew.zip (447 Bytes)