Page 1 of 1

Unicode To Ascii 1.0 [MM2+3]

Posted: Fri Jan 06, 2006 5:35 am
by trixmoto
This script (as requested) converts the text fields of the selected tracks from Unicode to ASCII. If the tags are already in ASCII, it will still convert them, but will obviously remain the same.

Code: Select all

'
' MediaMonkey Script
'
' NAME: UnicodeToAscii 1.0
'
' AUTHOR: trixmoto (http://trixmoto.net)
' DATE : 06/01/2006
'
' INSTALL: Copy to Scripts directory and add the following to Scripts.ini 
'          Don't forget to remove comments (') and set the order appropriately
'
' [UnicodeToAscii]
' FileName=UnicodeToAscii.vbs
' ProcName=UnicodeToAscii
' Order=16
' DisplayName=Unicode To Ascii
' Description=Convert Unicode To Ascii
' Language=VBScript
' ScriptType=0 
'

Option Explicit   

Sub UnicodeToAscii 
  Dim tracks,itm,prog
  Dim res, i

  Set tracks = SDB.SelectedSongList 
  If tracks.count = 0 Then 
     Set tracks = SDB.AllVisibleSongList 
  End If 
  If tracks.count = 0 Then 
    res = SDB.MessageBox("Select tracks to be converted", mtError, Array(mbOk)) 
    Exit Sub 
  End If 
  
  Set prog = SDB.Progress
  prog.MaxValue = tracks.count

  For i = 0 to tracks.count-1
    prog.Value = i
    prog.Text = "Converting track "&(i+1)&" of "&tracks.count&"..."
    Set itm = tracks.Item(i)
    
    itm.Title = SDB.toASCII(itm.Title)
    itm.ArtistName = SDB.toASCII(itm.ArtistName)
    itm.AlbumName = SDB.toASCII(itm.AlbumName)
    itm.AlbumArtistName = SDB.toASCII(itm.AlbumArtistName)
    itm.Genre = SDB.toASCII(itm.Genre)
    itm.Comment = SDB.toASCII(itm.Comment)
    itm.Author = SDB.toASCII(itm.Author)
    '.....
    
    itm.UpdateDB
    If prog.Terminate Then Exit For
  Next
  
  Set prog = Nothing
  res = SDB.MessageBox(tracks.count&" tracks successfully converted", mtInformation, Array(mbOk))
   
End Sub 

Sub Install()
  Dim inip : inip = SDB.ApplicationPath&"Scripts\Scripts.ini"
  Dim inif : Set inif = SDB.Tools.IniFileByPath(inip)
  If Not (inif Is Nothing) Then
    inif.StringValue("UnicodeToAscii","Filename") = "UnicodeToAscii.vbs"
    inif.StringValue("UnicodeToAscii","Procname") = "UnicodeToAscii"
    inif.StringValue("UnicodeToAscii","Order") = "16"
    inif.StringValue("UnicodeToAscii","DisplayName") = "UnicodeToAscii"
    inif.StringValue("UnicodeToAscii","Description") = "Convert Unicode To Ascii"
    inif.StringValue("UnicodeToAscii","Language") = "VBScript"
    inif.StringValue("UnicodeToAscii","ScriptType") = "0"
    SDB.RefreshScriptItems
  End If
End Sub

Posted: Wed Nov 07, 2007 11:36 am
by trixmoto
There is now an MM3 installation package available from my website for this script.

Posted: Wed Dec 26, 2007 6:38 am
by Macarena
Is there any way how to do this only for auto-organize procedure? I would not like to save my filenames with unicode characters as
a) some programs does not support them
b) I have fat32 file system and when later changing OS, it can cause some problems in reading -- definitely it's some uncertainty for me and I would like to get rid off it.

Thanks upfront

Posted: Wed Jan 02, 2008 5:03 am
by trixmoto
No, I don't think so, sorry.