Replace special characters (á -> a, ç -> c) from tags when naming the file

So I have an old system that uses Fat32 names and struggles with any non-ascii character in their display.

This means: á,é,í,ó,ú,ü or something else is represented as AE? or similar. I would like to see if there is any function that will convert them into their closest ascii equivalent (á -> a, ç -> c), but I couldn´t find anything.

I was wondering if there is anyway I can create a function clean(str) in which I get the str and perform several replacements to clean, I guess I could just nest several replacements into the line in case there is no other option.

Thank you.

Using the search function show this same question and answers:

or

and some more

Let us know if something very specific to your environment does not work as expected.

I saw those topics but validate does not help me.

The problematic characters are valid (I can use á in a filename as long as it is on NTFS drive), but when copied to a fat32 device the á is replaced by á so a song named: "ARTIST- Látigo" will be transferred as "ARTIST- Látigo"

This has two problem:

  • all the playlist item pointing to a song with an accent points now to a non-existing file and thus is skipped (because the name of the file is with the á, but the playlist path uses á)
  • the visualization on the screen will show the strange character

Basically I just need to create a function that search and replaces for all these characters:

á|a
é|e
í|i
ó|o
ú|u
Á|A
É|E
Í|I
Ó|O
Ú|U
ü|u
Ü|U
ñ|n
Ñ|N
è|e
ê|e
ì|i
î|i
ï|i
à|a
â|a
ò|o
ô|o
ù|u
û|u
ç|c
Ç|C
ß|ss
œ|oe
Œ|OE

As you can see the list is never ending, that is why I was asking if there is any way I can create my own function, because nesting replace() is not ideal.

You can use $replace like this:

$replace(%FIELDNAME_WITH_SPECIAL_CHARS%,á,a,é,e,í,i,ó,o,ú,u,Á,A,É,E,Í,I,Ó,O,Ú,U,ü,u,Ü,U,ñ,n,Ñ,N,è,e,ê,e,ì,i,î,i,ï,i,à,a,â,a,ò,o,ô,o,ù,u,û,u,ç,c,Ç,C,ß,ss,œ,oe,Œ,OE)

From the documentation about "multiple parameter pairs y and z":

That is perfect, thank you.

1 Like

BTW: You are missing the german vowels ä Ä and ö Ö in your list :wink:

I have restricted the list to the ones that I have encountered on my collection. I used to use tagscanner and got the list from there, but it just stopped working for renaming files.

It would be great to have a function with all variants of major european languages including the a with the circle on top of the o+/ by default.

I don't think I am the only person with this problem so it might be an existing list somewhere!

There is no function like "RemoveDiacritics" in Mp3tag.

But you can easily find such ready-to-use lists online, like this or this.

And there are other threads that also deal with some particularities, e.g.:

In case somewhere needs it this is the final function I have used:

$validate($replace($upper(%artist%)- %title%,á,a,é,e,í,i,ó,o,ú,u,Á,A,É,E,Í,I,Ó,O,Ú,U,ü,u,Ü,U,ñ,n,Ñ,N,è,e,ê,e,ì,i,î,i,ï,i,à,a,â,a,ò,o,ô,o,ù,u,û,u,ç,c,Ç,C,ß,ss,œ,oe,Œ,OE,!,,¿,,ä,a,Ä,A,ö,o,Ö,O),)

If you only need the replace part:

$replace(%FIELDNAME_WITH_SPECIAL_CHARS%,á,a,é,e,í,i,ó,o,ú,u,Á,A,É,E,Í,I,Ó,O,Ú,U,ü,u,Ü,U,ñ,n,Ñ,N,è,e,ê,e,ì,i,î,i,ï,i,à,a,â,a,ò,o,ô,o,ù,u,û,u,ç,c,Ç,C,ß,ss,œ,oe,Œ,OE,!,,¿,,ä,a,Ä,A,ö,o,Ö,O)