Need Help With "Case Conversion"; Scripts


#1

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?


#2

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) 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 for a more detailed explanation of a similar action.

You don't need any. *Practice. Further learning here http://help.mp3tag.de/main_scripting.html

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)


#3

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, 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.


#4

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 (138 Bytes)

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 http://help.mp3tag.de/options_format.html#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 :slight_smile:

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

_Script_Test_TEST.mta (138 Bytes)


#5

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. :laughing:


#6

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?

Best way to do that is use the :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'