# Need Help With "Case Conversion"; Scripts

**URL:** https://community.mp3tag.de/t/need-help-with-case-conversion-scripts/13708
**Category:** Support
**Created:** [July 31, 2012, 10:03pm UTC](https://community.mp3tag.de/t/need-help-with-case-conversion-scripts/13708 "2012-07-31T22:03:58Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![egg](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/e/6de8d8/32.png) [@egg](https://community.mp3tag.de/u/egg)
#### Post date: [July 31, 2012, 10:03pm UTC](https://community.mp3tag.de/t/need-help-with-case-conversion-scripts/13708/1 "2012-07-31T22:03:58Z")

</div>

Hey guys. I'm going to apologize in advance for asking about something which has likely been asked countless times before, but I'm having a very hard time finding the information I need.

Basically, I would like to run a "case conversion" which corrects filenames/tags to Mixed Case on slightly over 30k files. I found the stock Action for doing this in Mp3tag, but it has a few unwanted quirks. For instance, the filename "04 - W.A.S.P.mp3" is changed to "04 - W.a.s.p.mp3". Roman numerals are also affected in a similar manner. I'm sure this has been dealt with in the past.

I've tried searching for scripts that others have created, but the threads I'm finding usually contain a multitude of scripts from several users, none of which are fully explained. Since I have no programming knowledge, I have no idea what they actually do, and I'm not even sure I know how to implement them. Can someone point me in the right direction?

---

<div class="post-metadata">

### Author: ![stevehero](https://community.mp3tag.de/user_avatar/community.mp3tag.de/stevehero/32/337_2.png) [@stevehero](https://community.mp3tag.de/u/stevehero)
#### Post date: [August 1, 2012, 1:04am UTC](https://community.mp3tag.de/t/need-help-with-case-conversion-scripts/13708/2 "2012-08-01T01:04:21Z")

</div>

> [@Egg](#):
>
> Basically, I would like to run a "case conversion" which corrects filenames/tags to Mixed Case on slightly over 30k files. I found the stock Action for doing this in Mp3tag, but it has a few unwanted quirks. For instance, the filename "04 - W.A.S.P.mp3" is changed to "04 - W.a.s.p.mp3".

You have a couple of ways to do this and here are a those examples.

Begin Action Group **Clean-Up 1.2 # Case Retain CAPS With Title Case Elsewhere**** Action #1 **_Actiontype 5:_** Format value **_Field \_\_\_\_\_\_:_** \_FILENAME **_Formatstring:_** $caps2**(**%album% **,**' -(["'.-'**)End Action Group**Clean-Up 1.2 # Case Retain CAPS With Title Case Elsewhere** (1 Action)

Basically as you can see at the link below for further learning the **$caps2** doesn't change what is already caps. Which is what you require. The second parameter '**' -(["'.-'**' is optional and specifies additional characters that triggers upper case. In this case they are **-(["'.-**. Before **-** notice there is a whitespace (blank character).

You are going to have to add other actions to the group ([see here](https://community.mp3tag.de/t/967/1)) for other tags like ARTIST etc using the format value method.

OR use **Replace with regular expression** where you can affect \_ALL (all tags including filename)

 

Begin Action Group **\_Script Test#TEST**

 **Action #1** _Actiontype 4:_ **Replace with regular expression** _Field \_\_\_\_\_\_\_\_\_\_\_\_\_\_:_ **\_ALL** _Regular expression \_:_ **(^|\s|\.|\(|\[)([a-z])** _Replace matches with:_ **$1$caps2($2)** [\_] Case sensitive comparison 

End Action Group **\_Script Test#TEST** (1 Action)

 See [this post](http://forums.mp3tag.de/index.php?s=&s...ost&p=65567) for a more detailed explanation of a similar action.

> [@Egg](#):
>
> Basisally, I would like to Since I have no programming knowledge, I have no idea what they actually do, and I'm not even sure I know how to implement them. Can someone point me in the right direction?

 

You don't need any. \*Practice. Further learning here [https://docs.mp3tag.de/scripting](https://docs.mp3tag.de/scripting)

 

> [@Egg](#):
>
> Roman numerals are also affected in a similar manner. I'm sure this has been dealt with in the past.

 

I've seen a few of these actions around but none have been fully reliable on a large collection. So your safest option is to use this. This goes up to the roman numerals for 25. I find this does my job just fine. You could of you wanted to add the big ones like 'L' and 'C' for 50 and 100.

  

Begin Action Group **Clean-Up 1.2 # Case 'I' 'II' 'III' 'IV' 'V'**

 **Action #1** _Actiontype 4:_ **Replace with regular expression** _Field \_\_\_\_\_\_\_\_\_\_\_\_\_\_:_ **\_TAG** _Regular expression \_:_ **\b(i|ii|iii|iv|v|vi|vii|viii|ix|x|xi|xii|xiii|xiv|xv|xvi|xvii|xviii|xix|xx|x**

**xi|xxii|xxiii|xxiv|xxv)\b(?# abbreviations & acronyms)**

 _Replace matches with:_ **$upper($1)** [\_] Case sensitive comparison 

End Action Group **Clean-Up 1.2 # Case 'I' 'II' 'III' 'IV' 'V'** (1 Action)

---

<div class="post-metadata">

### Author: ![egg](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/e/6de8d8/32.png) [@egg](https://community.mp3tag.de/u/egg)
#### Post date: [August 1, 2012, 3:54am UTC](https://community.mp3tag.de/t/need-help-with-case-conversion-scripts/13708/3 "2012-08-01T03:54:29Z")

</div>

Thanks stevehero. I was hoping for something that does both the filename and the tags at the same time, but I'm not averse to using two separate actions if that's how it needs to be done. I gave your 2nd "\_Script Test#TEST" example a try, and it still changed "04 - W.A.S.P.mp3" to "04 - W.a.s.p.mp3".

In the time between my post and your response, I came across [this thread](https://community.mp3tag.de/t/11684/1), and managed to successfully create the following action:

Action: Replace with regular expression  
Field: \_ALL  
Regular expression: ([^,]\*)  
Replace matches with: $caps2($1)  
[] case-sensitive comparison

This actually works very well, but has a flaw. If a bracket is used and not closed, as in "04 - Chub (A Lub.mp3", the filename and title will be changed to [SYNTAX ERROR IN FORMATTING STRING]. The rest of the action scripts in that thread aren't really fully explained as far as what they do. It don't think I could dedicate enough time to figure out what those long character strings actually mean.

---

<div class="post-metadata">

### Author: ![stevehero](https://community.mp3tag.de/user_avatar/community.mp3tag.de/stevehero/32/337_2.png) [@stevehero](https://community.mp3tag.de/u/stevehero)
#### Post date: [August 1, 2012, 8:23am UTC](https://community.mp3tag.de/t/need-help-with-case-conversion-scripts/13708/4 "2012-08-01T08:23:16Z")

</div>

> [@Egg](#):
>
> Thanks stevehero. I was hoping for something that does both the filename and the tags at the same time, but I'm not averse to using two separate actions if that's how it needs to be done. I gave your 2nd "\_Script Test#TEST" example a try, and it still changed "04 - W.A.S.P.mp3" to "04 - W.a.s.p.mp3".

It can't possibly be. I tested it on the same file and it also works on the \_FILENAME and also the TITLE.

'sdfhsidfis (9dfsdfsd (dfsdfs) sdfsdfds [sdfsfg ffff wtf (it works just fine [w.a.s.p.].mp3' (Don't mind how random)  
**\>\>\>\>\>**  
 Sdfhsidfis (9dfsdfsd (Dfsdfs) Sdfsdfds [Sdfsfg Ffff Wtf (It Works Just Fine [W.A.S.P.].Mp3

Begin Action Group **\_Script Test#TEST**

**Action #1** _Actiontype 4:_ **Replace with regular expression** _Field \_\_\_\_\_\_\_\_\_\_\_\_\_\_:_ **\_ALL** _Regular expression \_:_ **(^|\s|\.|\(|\[)([a-z])**_Replace matches with:_ **$1$caps2($2)**[\_] Case sensitive comparison **Action #2** _Actiontype 4:_ **Replace with regular expression** _Field \_\_\_\_\_\_\_\_\_\_\_\_\_\_:_ **\_FILENAME** _Regular expression \_:_ **(\.\w{3,4}$)**_Replace matches with:_ **$lower($1)**[\_] Case sensitive comparison

End Action Group **\_Script Test#TEST** (2 Actions)

Its does change the .mp3 **\>\>\>\>\>**.Mp3 but because of the way it affects the \_FILENAME it alters it. You can fix this with an action in the same action group. I've attached the action so you can get a better understanding of action groups. As long as you have the actions in the order there here it will change the ext of the file to lowercase AFTER the other action #1 then #2 and so on. Make sure Action #2 only affects the \_FILENAME. Works for files such as .mp3 and .flac

[\_Script\_Test\_TEST.mta](https://community.mp3tag.de/uploads/default/original/2X/1/13ccdba7f547457a1a9e0a313392b12cb8536d2b.mta) (138 Bytes)

> [@Egg](#):
>
> Action: Replace with regular expression  
> Field: \_ALL  
> Regular expression: ([^,]\*)  
> Replace matches with: $caps2($1)  
> case-sensitive comparison
> 
> This  
> actually works very well, but has a flaw.

This picks up anything but a ',' (comma) and changes it to Title case not affecting the CAPS already there. Its too greddy of an expression.

Try my action. It should work just fine.

Reg exp is quite simple when you get your head around a few simple regexp matches.

**_\s_** matches one whitespace  
**\s+** is any amount of whitepaces  
**\s\*** matches one whitespace between 0 and infinity.

The last two things represent quantifiers. i.e the amount the whitespace happens.

See [https://docs.mp3tag.de/actions/replace-regexp](https://docs.mp3tag.de/actions/replace-regexp) on the complete list.

Take for example:

_Actiontype 4:_ **Replace with regular expression** _Field \_\_\_\_\_\_\_\_\_\_\_\_\_\_:_ **\_FILENAME** _Regular expression \_:_ **(\.\w{3,4}$)**_Replace matches with:_ **$lower($1)**

Just pick out the bits that are easy to understand.  
**.** represents '.'

  

All characters except **. | \* ? + ( ) { } ^ $**.  
These characters are literals when preceded by a "".

 

So any of the characters above NEED a \ placed in front of them to work.

 

**\w** Any word character - all alphanumeric characters plus the underscore

 

**{3,4}** between 3/4 times (again a quantifier)

 a{n,m} represents the letter "a" repeated between n and m times In this case the a is any word character represented by \w between 3/4 times matching things like .cats or .dogs :slight\_smile:  

But the important thing here is the **$**

 **$** anchors the position of the search at the END of the line So it only searches things like .mp3 and .flac because they are based at the end of the line/string 

Finally the two things on the outside **(** and **)** capture wants inside there. And the return **$lower($1)** changes that to all lowercase.

 

Hope I've cleared somethings up for you. If not maybe someone else will pick up on it 🙂

 

A great resource where I learned regexp was [http://www.regular-expressions.info/tutorial.html](http://www.regular-expressions.info/tutorial.html)

 

[\_Script\_Test\_TEST.mta](https://community.mp3tag.de/uploads/default/original/2X/1/13ccdba7f547457a1a9e0a313392b12cb8536d2b.mta) (138 Bytes)

---

<div class="post-metadata">

### Author: ![egg](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/e/6de8d8/32.png) [@egg](https://community.mp3tag.de/u/egg)
#### Post date: [August 1, 2012, 10:16pm UTC](https://community.mp3tag.de/t/need-help-with-case-conversion-scripts/13708/5 "2012-08-01T22:16:24Z")

</div>

Thanks again for your help stevehero. I gave it another shot when I got home today, and after a bit of frustration, (not entirely sure why) I got it working like a champ. I still need to do a bit more testing, but as of right now, it appears your scripts do exactly what I need. Thanks!

My next chore will be to find an action script which corrects any filenames that don't have the track number and/or correct spacing at the beginning (example of correct: 01 - Title.mp3 ). For now I'm very happy though. 😆

---

<div class="post-metadata">

### Author: ![stevehero](https://community.mp3tag.de/user_avatar/community.mp3tag.de/stevehero/32/337_2.png) [@stevehero](https://community.mp3tag.de/u/stevehero)
#### Post date: [August 2, 2012, 6:25am UTC](https://community.mp3tag.de/t/need-help-with-case-conversion-scripts/13708/6 "2012-08-02T06:25:18Z")

</div>

> [@Egg](#):
>
> I gave it another shot when I got home today, and after a bit of frustration, (not entirely sure why) I got it working like a champ.

Did you not just download the file in the above post and place it in your _...\Mp3tag\data\actions_ folder if you were having trouble?

> [@Egg](#):
>
> My next chore will be to find an action script which corrects any filenames that don't have the track number and/or correct spacing at the beginning (example of correct: 01 - Title.mp3 ).

Best way to do that is use the ![:mt_ttf:](https://community.mp3tag.de/uploads/default/original/1X/922db76db5d45b2e558d10f3d8c25fb8bc04fd27.png ":mt\_ttf:") and use:  
**Format string:** [**$num** ( **%track%** ,2)-] **%title%**

**This is the result:** If Track is present then \_FILENAME= '01 - Title.mp3"

Track not present then \_FILENAME= 'Title.mp3'

---

<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:23pm UTC](https://community.mp3tag.de/t/need-help-with-case-conversion-scripts/13708/7 "2026-02-09T12:23:58Z")

</div>


