Tag->filename -character substitution automation?


Hi! First timer here... So bare with me explaining (and in English).

I've used the MP3tag for a couple of ten thousand files and it's been a Big help. The program is great with it's extensive script options for tag and filename importing and exporting.

I was about to ask a guestion of the function Tag->filename. Is there a way to automatize the substitution of characters which use is restricted in filenames but do exist in the song title in tag?

For example, when you use the tag->filename -function for a lot of audio files at the same time which' tags contains characters in song names restricted in filenames, for example question marks (?), wich you would like everytime to be substituted with under scores (). Can it be set somewhere in the program to automaticaly substitute the restricted characters in file naming with the characters you can pre-set - very often dash (-) or underscore () depending of the original character to substitute?

In my opinion, if I'd get to choose which name I'd prefer more for an MP3-file titled "Tell me why?", a "01 - Tell me why.MP3" or "01 - Tell me why_.MP3" I'd definitely choose the latter becouse it's obvious that there belongs a question mark filling the underscore.

If this option is not available in the application, this would surely be one of the good things to add for the coming versions IMO - otherwise the app is pretty much perfect even for more advanced user. For e.g. the audio-CD ripper CDex has this option, altough it's not done even nearly perfectly.

Renaming from Freedb

Do you want to replace all special characters with one pre-defined character, or do you want to define a replacement character for each individual special character?
Basically, would you like to set that ? is replaced with , that </b> is replaced with A, that " is replaced with ', etc, or do you want to replace ?, ", </b>, etc. with ?

For the former, you can use an action of type Format values and do some $replace()s. For the later, simply use the function $validate() in the Tag-Filename formatstring.


-Exactly, that's what I wanna do. Care to try to simplify a bit how that is done? It's pretty hard to try to make a complete sense of the advanced features explained in the help file for me when it's all jargon and you're not native speaker.


Just a little addition for not to misunderstand my case, I don't want to replace any special characters in the tag fields, only when making filenames based on the tag values for the filenames.


The $replace(string,from,to) format string is pretty easy to understand, but as I see it you can only pre-define one restricted character to be substituted with another at a time?

If I'm to use the action tag->filename for a whole lot of audio files at the same time and I'd like the files to be in format:
%track% - %title%

And also I'd like the following substitutes automatically to be made for the following un-allowed characters in file names (equal-sign separates):

? = _

" = '' (two apostrophes)

/ or \ = -

: = -

  • = ^

< or > = _

| = _

How do you do this all at ones? That's my original guestion.


Well it gets a bit large...


Get's a bit large, you said it... :smiley:

Thanks a million! 'have to try it at once.


Worked like a charm, except for the part you apparently can't substitute the quotation mark (") with two apostrophes (''), which is one of the most important and best substitutes. With the format string provided above, it produces only one apostrophe instead of the quotation mark.

A thing to fix in the upcoming versions? maybe? :rolleyes:
I personally would welcome if the whole thingie would be integrated in the graphic user interface as in the option menu. I don't know, I might think many ppl could appreciate seeing this feature added. Or then I'm dead wrong and the only one. :huh:


You can make it a bit shorter by removing the four $replace() actions that convert to _ and replacing them with $validate().

$validate($replace($replace($replace($replace($replace(%track% - %title%,:,-),\,-),/,-),*,^),",''''),_)

I also changed the source expression to %track% - %title% since that's what you wanted.


I edited my formatstring - you have to use four apostrophes (formatstring has to contain twice the number of apostrophes you want to appear in the filename).


Ok. Everything works now perfectly. Needless to say, huge thanks man.

I originally also posted about this to Afterdawn.fi, and I think I'll later post there to my own post and explain what you answered and how it worked out.