# Making multiple words into one TAG (Filename-Tag)

**URL:** https://community.mp3tag.de/t/making-multiple-words-into-one-tag-filename-tag/3347
**Category:** Support
**Created:** [May 23, 2006, 5:11am UTC](https://community.mp3tag.de/t/making-multiple-words-into-one-tag-filename-tag/3347 "2006-05-23T05:11:19Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![kcnew](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/k/f07891/32.png) [@kcnew](https://community.mp3tag.de/u/kcnew)
#### Post date: [May 23, 2006, 5:11am UTC](https://community.mp3tag.de/t/making-multiple-words-into-one-tag-filename-tag/3347/1 "2006-05-23T05:11:19Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Sebastian\_Mares](https://community.mp3tag.de/user_avatar/community.mp3tag.de/sebastian_mares/32/9285_2.png) [@Sebastian\_Mares](https://community.mp3tag.de/u/Sebastian_Mares)
#### Post date: [May 23, 2006, 10:28am UTC](https://community.mp3tag.de/t/making-multiple-words-into-one-tag-filename-tag/3347/2 "2006-05-23T10:28:06Z")

</div>

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

---

<div class="post-metadata">

### Author: ![kcnew](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/k/f07891/32.png) [@kcnew](https://community.mp3tag.de/u/kcnew)
#### Post date: [May 23, 2006, 5:11pm UTC](https://community.mp3tag.de/t/making-multiple-words-into-one-tag-filename-tag/3347/3 "2006-05-23T17:11:43Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![dano](https://community.mp3tag.de/user_avatar/community.mp3tag.de/dano/32/6_2.png) [@dano](https://community.mp3tag.de/u/dano)
#### Post date: [May 23, 2006, 9:05pm UTC](https://community.mp3tag.de/t/making-multiple-words-into-one-tag-filename-tag/3347/4 "2006-05-23T21:05:56Z")

</div>

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:](https://community.mp3tag.de/uploads/default/original/1X/3a79e8b0b7d169b30216785521d7c6f4f895c421.gif ":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 😉 )

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

---

<div class="post-metadata">

### Author: ![kcnew](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/k/f07891/32.png) [@kcnew](https://community.mp3tag.de/u/kcnew)
#### Post date: [May 24, 2006, 12:05am UTC](https://community.mp3tag.de/t/making-multiple-words-into-one-tag-filename-tag/3347/5 "2006-05-24T00:05:49Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![dano](https://community.mp3tag.de/user_avatar/community.mp3tag.de/dano/32/6_2.png) [@dano](https://community.mp3tag.de/u/dano)
#### Post date: [May 24, 2006, 6:44am UTC](https://community.mp3tag.de/t/making-multiple-words-into-one-tag-filename-tag/3347/6 "2006-05-24T06:44:18Z")

</div>

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](https://community.mp3tag.de/t/2584/1)

[kcnew.zip](https://community.mp3tag.de/uploads/default/original/2X/a/a3078869c8f7e670b06c55c7af1ac93d14cd81f8.zip) (447 Bytes)

---

<div class="post-metadata">

### Author: ![system](https://community.mp3tag.de/uploads/default/original/2X/c/ce7035d426cb755a7916793326d23b465222a407.png) [@system](https://community.mp3tag.de/u/system)
#### Post date: [February 9, 2026, 12:19pm UTC](https://community.mp3tag.de/t/making-multiple-words-into-one-tag-filename-tag/3347/7 "2026-02-09T12:19:45Z")

</div>


