INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: Replace non ascii characters in album, artist, composer fields  (Read 1636 times)

jacobacci

  • Galactic Citizen
  • ****
  • Posts: 256
Replace non ascii characters in album, artist, composer fields
« on: November 18, 2015, 04:25:42 pm »

While cleaning up my library, I have run into problems with non ascii characters in my album, artist, composer fields (as I use them in my directory structure). To be on the safe side, I would like to replace all the non ascii characters in these fields with either an underscore or (better) with their ascii equivalent.
eg:
ö -> oe
ä -> ae
ü -> ue
é -> e
etc.
Has anyone done something like this before? This almost smells of RexEx as a solution.
Logged

ferday

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1732
Re: Replace non ascii characters in album, artist, composer fields
« Reply #1 on: November 18, 2015, 04:45:47 pm »

you could regex it

i would probably try and figure out a regex, it seems easier....but in the meantime a simple replace works (i just tested quick)

replace([name],ö,oe)

i tested with a short

ifelse(isequal([name],ö,8),replace([name],ö,oe),isequal([name],é,8),replace([name],é,e),[name])

and that works as well so in theory if you are determined you could write a single expression that contains all the characters of interest and do all the names at once
Logged

blgentry

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 8014
Re: Replace non ascii characters in album, artist, composer fields
« Reply #2 on: November 18, 2015, 04:48:42 pm »

I've played with this, but it's complicated.  My chosen approach was this:

1.  Operate on an exported playlist in MPL format.  This contains all of the library fields and their values and is human readable.
2.  I wrote a program which uses a library that knows how to translate UTF-8 characters with accents into their ascii equivalents, so it can produce "safe" output from chosen fields like Artist, Album, and Name.
3.  I save these ascii representations of the chosen fields into *NEW* field names like ascii_Album.  These get written to a new MPL file along with all of the original fields.
4.  This resulting MPL file can be imported into MC, and the new fields will be populated with their ASCII values.  This way the existing library data is safe and not modified.  Of course you have to create these new library fields first, but that's easy.  :) 
5.  Finally, once you have the ascii equivalent fields in place, you can use Rename, Move, and Copy to change file or directory names (or both).  You could also use expressions to copy these new ascii fields into existing fields if you wanted.

My program is super duper alpha quality.  That is, it has undergone VERY little testing.  I only played with it for about a few days.  It's written in Python, which requires a small installation on windows to make Python work.

Oh, I also wrote some expressions to replace selected characters, but they get REALLY big really fast because you need one replace expression per pair of characters.  It's ugly, ugly, ugly.  But it works if you only have a small number of special characters you are trying to substitute.

I don't know if this helps you or not, but that's my story.  :)

Brian.
Logged

jacobacci

  • Galactic Citizen
  • ****
  • Posts: 256
Re: Replace non ascii characters in album, artist, composer fields
« Reply #3 on: November 18, 2015, 05:20:14 pm »

Thanks guys,
So far I have taken the simple approach to search and replace the usual suspects öäüéàè and the eastern European counterparts. That has worked quite well.
Based on Brian's suggestion I think I could
- export a playlist in MPL format
- run a program across it that finds non ascii characters
- do a manual search an replace for these characters within JRiver
The obvious ones are done, there can't be many left
Thanks for sharing.
Logged
Pages: [1]   Go Up