Replace Accents


#1

Is there a way to remove accents without creating a replace action for each letter.

I want to replace all "á é í ó ú" with "a e i o u"

Is creating replace actions for each letter under an action group the only way to achieve this. :unsure:


Suggestion: $translate function
#2

Is creating replace actions for each letter under an action group the
only way to achieve this.

I'd say Yes, given Florian (Mp3tag developer)'s reply to the similar question at: Reducing filename to ASCII

If you want to cover uppercase too, you'll need separate Replace actions for those. Also you might want to add ñ and ü.


#3

By the way, if your goal is pathname compatibility or string comparability, $ansi() might do the job better - it is a lot more concise, and covers other possibly non-Extended ASCII characters too.


#4

Is there a table list anywhere in the documentation to see what $ansi() converts in reality char by char?

DD.20080221.2154.CET


#5

Yes I'll love to learn more about it can you point us to the right direction.


#6

$ansi() converts the given string using the current system codepage. So there is no fixed list of characters since the result depends on the host system's active codepage.


#7

I'd be interested to know it's unicode>CP mapping. If the operation corresponds to a Windows API function, could you tell us which?


#8

Hi, I tired to use the $ansi() function in the parameter of a tool, but doesn't seem to work.

The tool is this (inspired by this post):

http://www.allmusic.com/cg/amg.dll?p=amg&opt1=2&sql=$replace($ansi(%album%), ,+)

I also tried the other way round, just in case, but I doesn't work either:

http://www.allmusic.com/cg/amg.dll?p=amg&opt1=2&sql=$ansi($replace(%album%, ,+))

Name of the tool (for those interested): AMG - Album
Path: pointing to "firefox.exe"
[ ] for all selected files (not marked)

There seems to be only one way to correct this for me (veeeeeery ad hoc, let's say):

http://www.allmusic.com/cg/amg.dll?p=amg&opt1=2&sql=$replace($replace($replace($replace($replace($replace(%album%, ,+),á,a),é,e),í,i),ó,o),ú,u)

The album in question is "Verve Jazz Masters 11: Stéphane Grappelli", so the idea of using several $replace function works, but I'd need to modifiy it to allow other characters every time I need it. That's very tedious.

Any other idea?


#9

$ansi only deals with caracters that do not fit in your system codepage
For example win1252 which you probably have:
http://en.wikipedia.org/wiki/Windows-1252
All these characters stay the same.

Btw $replace does not have to be nested:
$replace(%album%, ,+,á,a,é,e,í,i,ó,o,ú,u)


#10

That's much better, it would be worth adding it to the help file. :wink:
And a function to perform this in a simpler way (directily) would be welcome too.

Thanks dano


#11

Please?


#12

Florian, could you please make this function override official? It is not mentioned anywhere in the Help as far as I can see. Thanks.


#13

It's already mentioned at Help > Scripting functions.


#14

Oh OK! Sorry.


#15

Not a problem at all :slight_smile:


#16

I know this is an old topic, but I wanted to add some thoughts on codepage 1252 [or other pages or unicode) and removing accented characters. The samples below should help with most European languages. Removing accents is a very 'English' thing to want to do, and the resulting names will make less sense to other nationalities! However if you have a large music collection, inconsistently tagged over time, it's much easier afterwards to find all references to an artist.

I'm copy/pasting from a spreadsheet so I can't be sure the text will look correct or not, and you should try copy/pasting from this page back into your package of choice. Although created in WIndows language=En-UK, I think this will work for many of you. I Can't guarantee the code will make sense after posting - I'll check and the post a file if need be.

If you copy multi-line please remove breaks to make one line of text for each command.

For example:

$replace(%album%,À,A,Á,A,Â,A,Ã,A,Ä,A,Å,A,à,a,á,a,â,a,ã,a,ä,a,å,a,Æ,AE,æ,ae,Ç,C,ç
,c,È,E,É,E,Ê,E,Ë,E,è,e,é,e,ê,e,ë,e,Ì,I,Í,I,Î,I,Ï,I,ì,i,í,i,î,i,ï
,
i,Ñ,N,ñ,n,Ò,O,Ó,O,Ô,O,Õ,O,Ö,O,Ø,O,ò,o,ó,o,ô,o,õ,o,ö,o,ø,o,Œ,OE,œ
,
oe,Š,S,š,s,ß,ss,Ð,Th,Þ,Th,ð,th,þ,th,Ù,U,Ú,U,Û,U,Ü,U,ù,u,ú,u,û,u,ü
,
u,Ÿ,y,Ý,Y,ý,y,ÿ,y,Ž,Z,ž,z)
$replace(%artist%,À,A,Á,A,Â,A,Ã,A,Ä,A,Å,A,à,a,á,a,â,a,ã,a,ä,a,å,a,Æ,AE,æ,ae,Ç,C,ç
,c,È,E,É,E,Ê,E,Ë,E,è,e,é,e,ê,e,ë,e,Ì,I,Í,I,Î,I,Ï,I,ì,i,í,i,î,i,ï
,
i,Ñ,N,ñ,n,Ò,O,Ó,O,Ô,O,Õ,O,Ö,O,Ø,O,ò,o,ó,o,ô,o,õ,o,ö,o,ø,o,Œ,OE,œ
,
oe,Š,S,š,s,ß,ss,Ð,Th,Þ,Th,ð,th,þ,th,Ù,U,Ú,U,Û,U,Ü,U,ù,u,ú,u,û,u,ü
,
u,Ÿ,y,Ý,Y,ý,y,ÿ,y,Ž,Z,ž,z)

Greek:

$replace(%album%,Α,A,Β,B,Γ,G,Δ,D,Ε,E,Ζ,Z,Η,I,Θ,TH,Ι,I,Κ,K,Λ,L,Μ,M,Ν,N,Ξ,X,Ο,O,Π,
P,Ρ,R,Σ,S,Τ,T,Υ,Y,Φ,PH,Χ,CH,Ψ,PS,Ω,O,α,a,β,b,γ,g,δ,d,ε,e,ζ,z,η,i,


#17

Useful - thanks.

Some others do it too. E.g. SADAIC (Argentina's composers' royalty collection agency) omits all accents from work titles e.g. in its database at www.sadaic.org.ar .

It is also necessary to make filenames that are sure to survive Windows CMD processing or transfer on FAT32 between Windows OSes having different regional settings.


#18

See also ...
Unicode to Ascii
Unicode to ASCII

DD.20111223.0822.CET