Character remapping during conversion?


#1

Hi - I would like to know if there is a way to have certain characters remapped when I convert Tag > Filename. Ideally, I would like a template that I could use to create an action group so that I could add more characters as I need them. However, I don't see how to do this. I can obviously create a "replace" function, but this would not help me when converting. I see this on the Help page:

Remove invalid characters from file name/file paths

Command: $validate(filename,to)
Example: $validate(%artist% - %album% - %track% - %title%,-)
This example replaces all invalid characters (/?*"<>|:slight_smile: to dashes.

This is sort of what I want, except I want to make it so that each one of those invalid characters gets changed to something else that I choose.

BTW, can the example above just be entered in the format string field when converting Tag > Filename? The help file sort of indicates this, but it does not do what is expected.

I did look at the regular expression threads in the forum, but again, I still don't know how I would make something like this happen only when converting.

Thanks!


#2

The function $validate() is able to make a text string valid to be used as a name in the filesystem.
If that is, what you want to do, then use this function.

Otherwise characters or strings can be replaced by the functions $replace() or $regexp(), or by the actions "Replace", "Replace with Reglar Expression".

You should be more specific what you really want to achieve.

DD.20120201.2059.CET


#3

Hi and thanks for replying - OK, an example of what I want to do is this:

If the title of the track in the tag is: Open/Close

When I convert from Tag > Filename, I want it to be: Open-Close

I want this to be automatic, so whenever I convert Tag > Filename, this will occur, and any other invalid characters can be remapped to something else as well (colon to semicolon, quotes to 2 single quotes, etc.). A global setting for character remapping when naming files would be ideal.

I am confused as to how I could use a replace action to accomplish this, since this would only be required on a conversion. In other words, what is there to replace in a filename if the character only exists in the tag?

Please let me know if this is clear or not. Thanks again!


#4

If you want to convert the filenam to: %artist% - %title%.mp3 with your replaces, use the following for the converter:
$replace(%artist% - %title%,/,-,:,;,",'''')
You can expand that list of replacement for all characters you want.
Note that you have to use four single quotes instead of two, because the have to be "escaped" from the Mp3tag script syntax.


#5
$validate

Usage: $validate(,)

Following invalid characters will be replaced with ReplaceChar:
034 "
042 *
047 /
058 :
060 <
062 >
063 ?
124 |

"*/:<>?|

$validate allows the colon to exist at position 2 counted from the left edge of the string, when used as the separator for the drive letter.

"E:\abc"
... is allowed

" E:\abc"
... is not allowed and will give ...
" E_\abc"

Examples:

Clean Path $validate($regexp('x ... E: \ ... Music \ ...\ ... Artist *2*\ Title 3 ... x','(?:^|(?<=\\\\))[ .]+|[ .]+(?:(?=\\\\)|$)',),'_') Result = "x ... E_\Music\_Album 1_\Artist _2_\Title 3 ... x" $validate($regexp(' ... E: \ ... Music \ ...\ ... Artist *2*\ Title 3 ... ','(?:^|(?<=\\\\))[ .]+|[ .]+(?:(?=\\\\)|$)',),'_') Result = "E:\Music\_Album 1_\Artist _2_\Title 3" Note: $validate respects the colon at the second string position. $validate($regexp(' ... E: \ ... Music \ ...\ ... Artist *2*\ Title 3 ... ','(?:^|(?<=\\\\))[ .]+|[ .]+(?:(?=\\\\)|$)',),) Result = "E:\Music\Album 1\Artist 2\Title 3" Note: $validate respects the colon at the second string position. $replace

The function $replace(,,) is case-sensitive.
To this function a plurality of 'from,to' pairs can be passed:

$replace(string,from,to[,from,to]...)


Example: $replace(%TEST%,'ä','ae','ö','oe','ü','ue','Ä','Ae','Ö','Oe','Ü','Ue','ß','ss')

DD.20120201.2145.CET


Beim Konverter Tag - > Dateimane" Zeichen ersetzen
[X] Title has "/" - > Filename
Problems with pushing tags to filenames
"Filename - Tag" ICON
#6

Thank you! This is exactly what I was looking for. I have just changed my default convert strings to include this. Saves a LOT of time! Much appreciated.


#7

Thank you for this! It will definitely come in handy. I clearly have some reading to do...


#8
Remove invalid characters from file name/file paths

Command: $validate(filename,to)
Example: $validate(%artist% - %album% - %track% - %title%,-)
This example replaces all invalid characters (/?*"<>|:slight_smile: to dashes.

How can I modify

$validate(%track%-%title%,-)

to pad the track number to two characters? I have tried but failed dismally. :stuck_out_tongue: Thanks in advance.


#9

Matt, the theme of this thread is "Character remapping during conversion?" but not how to pad a track number.
Please post your question under your own thread and do not hijack this thread.
Please read the FAQ area.
Please read the forum, you will find answers to your question every two days, at least evey week back in time.
As April 2009 registered user you should know this by yourself.
Maybe there is an answer ...
[F] problems with ":" when renaming file

I beg your pardon for my rude words.
Why do you post a citation from the FAQ area regarding function $validate here in this thread and ask a non relevant question about the function $num ? ? ?

DD.20120203.0700.CET


#10

Hey guys - I just noticed I spelled "Remapping" wrong in the thread title. Is there any way to correct it so this helpful thread will show up if someone searches for the same terms? Thanks!


#11

That was fast - thanks!


#12

Detlev, could you not have simply answered my question in about 1% of the number of characters you used to be unpleasant to me? In the past you have been helpful, and I have been polite and appreciative, but this leaves a sour taste with me.

Also please remember that not everyone is a super genius like yourself. Most of this stuff looks like Chinese to some people. If you see someone asking a question very similar to your own, sometimes you have to grab at that straw.

In fact, basically I was asking the same question in as the original post, with the proviso that it doesn't mess up my usual practice of having 2-digit track numbers!!

So I modifed this line from the original post:

Example: $validate(%artist% - %album% - %track% - %title%,-)

to:

$validate(%track%-%title%,-)

and asked a question about what to do next! What's so irrelevant about that?

[And BTW in fact I found the original post by ... searching!!]


#13

Hmm, I did read a different question from you, than the question from the open poster, who asked for "Character remapping".
You asked for ...

On some days I'm just too tired to answer the same simplest questions over and over again.

Matt, in your case, one got the feeling to have been intentionally kidded, because the answer to your own question is in your own post (see citation link above, pointing to your post).

If you are not able to understand your own example in your own post, then try to understand the example in Mp3tag Manual
http://help.mp3tag.de/main_scripting.html
Topic
Pad decimal number with leading zeros

DD.20120203.2000.CET


#14

[quote name='DetlevD' post='61517']
Hmm, I did read a different question from you, than the question from the open poster, who asked for "Character remapping".
You asked for ...

Yes, the original post asked for character remapping, and I was asking about character remapping so it conforms to my usual practice, i.e. asking a related follow-up question. So shoot me.

On some days I'm just too tired to answer the same simplest questions over and over again.

They may be simple to you but not necessarily to everyone else. I am not ashamed to say I don't understand and ask for help. You can be a genius, but that doesn't mean you have to bite the head off someone less knowledgeable than yourself.

Matt, in your case, one got the feeling to have been intentionally kidded, because the answer to your own question is in your own post (see citation link above, pointing to your post).

OK, so I asked that question before, a long time ago, and since a lot of water has gone under the bridge since then I had forgotten. Funny how that post didn't come up no.1 in my search result, whereas this thread did. Maybe you could have just have given a little wink and reminded me. Remember patience is a virtue, and a bit of good humour doesn't hurt too.

And yes, I'm too stupid to work out how to quote properly, hence the bold letters.


#15

Hmm ... about 1% of the number of characters? ==> read FAQ

DD.20120204.1520.CET