The code for FixCase.vbs file is here:
Code: Select all
' This script fixes case (Uppercase or Lowercase problems) of several fields
Dim CaseExceptions ' Exceptions in case conversions
Set CaseExceptions = CreateObject("Scripting.Dictionary")
' The first strings are expected to be fully in lowercase
CaseExceptions.Add "to", "to"
CaseExceptions.Add "in", "in"
CaseExceptions.Add "and", "and"
CaseExceptions.Add "on", "on"
CaseExceptions.Add "of", "of"
CaseExceptions.Add "ac", "AC" ' Handle AC/DC name ;-)
CaseExceptions.Add "dc", "DC"
CaseExceptions.Add "a", "a"
CaseExceptions.Add "the", "the"
CaseExceptions.Add "i", "I" ' handle Greek numbers
CaseExceptions.Add "ii", "II"
CaseExceptions.Add "iii", "III"
CaseExceptions.Add "iv", "IV"
CaseExceptions.Add "vi", "VI"
CaseExceptions.Add "vii", "VII"
CaseExceptions.Add "viii", "VIII"
CaseExceptions.Add "ix", "IX"
CaseExceptions.Add "xi", "XI"
CaseExceptions.Add "xii", "XII"
CaseExceptions.Add "xiii", "XIII"
CaseExceptions.Add "xiv", "XIV"
CaseExceptions.Add "xv", "XV" ' up to 15 should be enough...
CaseExceptions.Add "n", "n" ' handle "Rock n Roll"
Function DoCaseFix( src, UpperCaseOnlyFirst)
Dim result, pos, srclen, startpos, ch, word, first, rest, i, forcelower
src = LCase( src)
pos = 1
srclen = Len( src)
first = True
forcelower = False
Do While pos<=srclen
startpos = pos
Do While pos<=srclen
ch = Asc( Mid( Src, pos, 1))
If (ch<97) Or ((ch>122) and (ch<129)) Then
Exit Do
End If
pos = pos + 1
Loop
If pos>startpos Then
' We found a word, check if it isn't an exception and process it accordinly
word = Mid( src, startpos, pos-startpos)
If CaseExceptions.Exists(word) Then
word = CaseExceptions( word)
If first Then
result = result + UCase( Left( word, 1)) + Mid( word, 2)
Else
result = result + word
End If
Else
If UpperCaseOnlyFirst And Not first Then
' All characters go to lower-case, except for the first one
result = result + word
Else
' Put the first letter to upper-case
If forcelower then
result = result + word
Else
result = result + UCase( Left( word, 1)) + Mid( word, 2)
End If
End If
End If
End If
first = False
forcelower = False
startpos = pos
Do While pos<=srclen
ch = Asc( Mid( Src, pos, 1))
If Not((ch<97) Or ((ch>122) and (ch<129))) Then
Exit Do
End If
pos = pos + 1
Loop
' simply copy all other characters
rest = Mid( src, startpos, pos-startpos)
i = Len( rest)
If i>0 Then
ch = Asc( Right( rest, 1))
If ch=46 Then ' '.' causes the next letter to be uppercased
first = True
End If
If (ch=39) or (ch=96) Then
forcelower=True
End If
End If
result = result + rest
Loop
DoCaseFix = result
End Function
Sub FixCaseAll
' Define variables
Dim list, itm, i, tmp
' Get list of selected tracks from MediaMonkey
Set list = SDB.SelectedSongList
If list.count=0 Then
Set list = SDB.AllVisibleSongList
End If
' Process all selected tracks
For i=0 To list.count-1
Set itm = list.Item(i)
' Fix case for some fields
itm.ArtistName = DoCaseFix( itm.ArtistName, False) ' do artist and album at first as they can cause re-read of data
itm.AlbumName = DoCaseFix( itm.AlbumName, False)
itm.Title = DoCaseFix( itm.Title, False)
' Update the changes in DB
itm.UpdateDB
Next
End Sub
Sub FixCaseFirst
' Define variables
Dim list, itm, i, tmp
' Get list of selected tracks from MediaMonkey
Set list = SDB.SelectedSongList
If list.count=0 Then
Set list = SDB.AllVisibleSongList
End If
' Process all selected tracks
For i=0 To list.count-1
Set itm = list.Item(i)
' Fix case for some fields
itm.ArtistName = DoCaseFix( itm.ArtistName, True) ' do artist and album at first as they can cause re-read of data
itm.AlbumName = DoCaseFix( itm.AlbumName, True)
itm.Title = DoCaseFix( itm.Title, True)
' Update the changes in DB
itm.UpdateDB
Next
End Sub
Code: Select all
[FixCaseAll]
FileName=FixCase.vbs
ProcName=FixCaseAll
Order=16
DisplayName=Start all words in &Upper-case
Description=Start all words in upper-case
Language=VBScript
ScriptType=0
[FixCaseFirst]
FileName=FixCase.vbs
ProcName=FixCaseFirst
Order=17
DisplayName=Start the first word in U&pper-case
Description=Start the first word in upper-case
Language=VBScript
ScriptType=0