TitleCase.vbs

Download and get help for different MediaMonkey Addons.

Moderators: Peke, Gurus

Peke
Posts: 11449
Joined: Tue Jun 10, 2003 7:21 pm
Location: Serbia
Contact:

Post by Peke » Wed Apr 13, 2005 6:51 pm

Got it. Still It Does not work but reports OLE error. I'll see what is wrong.
Best regards,
Pavle
MediaMonkey Team lead QA/Tech Support guru
Admin of Free MediaMonkey addon Site HappyMonkeying
Image
Image
How to add Images to forum

judas
Posts: 572
Joined: Thu Jun 02, 2005 11:26 pm
Location: Bogotá, Colombia

Post by judas » Tue Jul 12, 2005 1:52 am

Its a beautiful script indeed..i have one question though...i have all the Artists in UPPER CASE...yes..no exceptions: McCartney is MCCARTNEY and the like...i edited the script so it wouldnt update the artist (i put a ' in where it makes artist=editedArtist :-)

is it hard to modify the script so it turns the artist to uppercase? if it isnt, can someone please help me with that?

thank you...you guys rock!

judas
Posts: 572
Joined: Thu Jun 02, 2005 11:26 pm
Location: Bogotá, Colombia

Post by judas » Wed Jul 20, 2005 7:06 pm

mmmm....no one answered so im nudging the topic now :-)...

Bex
Posts: 6316
Joined: Fri May 21, 2004 5:44 am
Location: Sweden

Post by Bex » Wed Jul 20, 2005 7:23 pm

There is a script somewhere in the forum that can update to uppercase (but not only artist). Search for it and modify it and you'll get what you want!

judas
Posts: 572
Joined: Thu Jun 02, 2005 11:26 pm
Location: Bogotá, Colombia

Post by judas » Thu Jul 21, 2005 11:20 am

i have been looking for the UPPER CASE script but havent been able to find it

...mmm..anyway...if someone can help me here i would really appreciate it.

thanks...

:lol:

Bex
Posts: 6316
Joined: Fri May 21, 2004 5:44 am
Location: Sweden

Post by Bex » Thu Jul 21, 2005 4:23 pm

judas wrote:i have been looking for the UPPER CASE script but havent been able to find it

...mmm..anyway...if someone can help me here i would really appreciate it.

thanks...

:lol:
Here you go!
http://www.mediamonkey.com/forum/viewtopic.php?t=949

judas
Posts: 572
Joined: Thu Jun 02, 2005 11:26 pm
Location: Bogotá, Colombia

Post by judas » Fri Jul 22, 2005 11:46 am

bex, thanx a lot for that man but..i had seen that...it capitalizes the first letter of a word...as in title case...i need to convert the entire artist name to uppercase..maybe its just changing a word in the script or something.
shouldnt be hard to implement though...

thanx,

Bex
Posts: 6316
Joined: Fri May 21, 2004 5:44 am
Location: Sweden

Post by Bex » Fri Jul 22, 2005 12:32 pm

judas wrote:bex, thanx a lot for that man but..i had seen that...it capitalizes the first letter of a word...as in title case...i need to convert the entire artist name to uppercase..maybe its just changing a word in the script or something.
shouldnt be hard to implement though...

thanx,
Ok, i thought that the option "Start all words in Upper-case" was what you were looking for. But I see now that it isnt.

MrData

Addition to otherwise excellent script

Post by MrData » Tue Jul 26, 2005 7:21 am

Greeting all,

I've seen numerous posts on requests for updating case in various fields.

I myself, because of the MP3 player I have in my car, like all information (title, artist, album title) in lowercase, 'cause I find this easier on the eyes. Plus it resolves all 'And', 'By' etc. matters.

But that's just personal.

Anyways, I've added to the above script two functions that either changes ALL information (the same as in the original script: title, artist, album title, album artist) in lowercase or in UPPERCASE. The original function to change only the first letters in Capitals is also kept.

Place the following code AT THE VERY END of the TitleCase.vbs script (these are two functions that will be added in the menu of MM)

Code: Select all

Sub TitleCaseLower()
   Dim UI, Form, Foot, Btn, Btn2, WB, doc
    
   Dim trackList
   Dim writeChanges

   Set trackList = SDB.SelectedSongList
   If trackList.Count = 0 Then
      Set trackList = SDB.AllVisibleSongList
   End If

   If trackList.Count = 0 Then
      res = SDB.MessageBox("Select tracks to be updated", mtError, Array(mbOk))
      Exit Sub
   End If


   Set UI = SDB.UI

   ' Create the window to be shown
   Set Form = UI.NewForm
   Form.Common.SetRect 50, 50, 500, 400
   Form.Common.MinWidth = 200
   Form.Common.MinHeight = 150
   Form.FormPosition = mmFormScreenCenter
   Form.SavePositionName = "CaseWindow"
   Form.Caption = SDB.Localize("Changes to Case")
   Form.StayOnTop = True

   ' Create a panel at the bottom of the window
   Set Foot = UI.NewPanel(Form)
   Foot.Common.Align = mmAlignBottom
   Foot.Common.Height = 35

   ' Create a button that closes the window
   Set Btn = UI.NewButton(Foot)
   Btn.Caption = SDB.Localize("&Cancel")
   Btn.Common.SetRect (Foot.Common.Width - 180) / 2 + 95, 9, 85, 24
'   Btn.Common.SetRect Foot.Common.Width - 90, 9, 85, 24
   'Btn.Common.Hint = SDB.Localize("Close this report")
   Btn.Common.Anchors = mmAnchorRight + mmAnchorBottom
   Btn.UseScript = Script.ScriptPath
   Btn.OnClickFunc = "OnCancel"

   ' Create a button that saves the report
   Set Btn2 = UI.NewButton(Foot)
   Btn2.Caption = SDB.Localize("&OK")
'   Btn2.Common.SetRect Foot.Common.Width - 90 - 5 - btn.common.width - 5, 9, 85, 24
   Btn2.Common.SetRect (Foot.Common.Width - 180) / 2, 9, 85, 24
   'Btn2.Common.Hint = SDB.Localize("Save this report")
   Btn2.Common.Anchors = mmAnchorRight + mmAnchorBottom
   Btn2.UseScript = Script.ScriptPath
   Btn2.OnClickFunc = "OnOK"

   ' Create a web browser component
   Set WB = UI.NewActiveX(Form, "Shell.Explorer")
   WB.Common.Align = mmAlignClient      ' Fill all client rectangle
   WB.Common.ControlName = "WB"
   WB.Interf.Navigate "about:"          ' A trick to make sure document exists
   Set doc = WB.Interf.Document

   Form.Common.Visible = True                ' Only show the form, don't wait for user input
   SDB.Objects("CaseThingy") = Form  ' Save reference to the form somewhere, otherwise it would simply disappear


   doc.write "<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.0 Transitional//EN"">" & vbCrLf
   doc.write "<html>" & vbCrLf
   doc.write "  <head>" & vbCrLf
   doc.write "    <title>" & SDB.Localize("Changes to Case") & "</title>" & vbCrLf
   doc.write "  </head>" & vbCrLf

   doc.write "<STYLE TYPE=text/css>" & vbCrLf
   doc.write "body{font-family:'Verdana',sans-serif; background-color:#FFFFFF; font-size:9pt; color:#000000;}" & vbCrLf
   doc.write "H1{font-family:'Verdana',sans-serif; font-size:13pt; font-weight:bold; color:#AAAAAA; text-align:left}" & vbCrLf
   doc.write "P{font-family:'Verdana',sans-serif; font-size:8pt; color:#000000;}" & vbCrLf
   doc.write "TH{font-family:'Verdana',sans-serif; font-size:9pt; font-weight:bold; color:#000000; border-color:#000000; border-style: 

solid; border-left-width:0px; border-right-width:0px; border-top-width:0px; border-bottom-width:3px;}" & vbCrLf
   doc.write "TD{font-family:'Verdana',sans-serif; font-size:8pt; color:#000000; border-color:#000000; border-style: solid; 

border-left-width:0px; border-right-width:0px; border-top-width:0px; border-bottom-width:1px;}" & vbCrLf
   doc.write "TD.highlight{font-family:'Verdana',sans-serif; font-size:8pt; background-color:#FFFF77; color:#000000; 

border-color:#000000; border-style: solid; border-left-width:0px; border-right-width:0px; border-top-width:0px; 

border-bottom-width:1px;}" & vbCrLf
   doc.write "TR.dark{background-color:#EEEEEE}" & vbCrLf
   doc.write "TR.aleft TH{text-align:left}" & vbCrLf
   doc.write "</STYLE>" & vbCrLf

   doc.write "  <body>" & vbCrLf
   doc.write "    <H1>" & SDB.Localize("Changes to Case:") & "</H1>" & vbCrLf
   doc.write "    <table border=""0"" cellspacing=""0"" cellpadding=""4"" width=""100%"">" & vbCrLf
'   doc.write "          <tr><th colspan=""4"">" & SDB.Localize(title) & "</th></tr>" & vbcrlf
   doc.write "      <tr class=""aleft"">" & vbCrLf
   doc.write "        <th>" & SDB.Localize("Artist") & "</th>" & vbCrLf
   doc.write "        <th>" & SDB.Localize("Title") & "</th>" & vbCrLf
   doc.write "        <th>" & SDB.Localize("Album") & "</th>" & vbCrLf
   doc.write "        <th>" & SDB.Localize("Album Artist") & "</th>" & vbCrLf
   doc.write "      </tr>" & vbCrLf

   Dim i, itm
   Dim artist, album, title, albumArtist
   For i = 0 To trackList.Count - 1
      doc.write "      <tr" & Style() & ">" & vbCrLf

      Set itm = trackList.Item(i)
      artist = LCase(itm.artistName)
      title = LCase(itm.title)
      album = LCase(itm.albumName)
      albumArtist = LCase(itm.albumArtistName)
      
      doc.write outField(artist, itm.artistName)
      doc.write outField(title, itm.title)
      doc.write outField(album, itm.albumName)
      doc.write outField(albumArtist, itm.albumArtistName)
      If artist <> "" And artist <> itm.artistName Then
         holdArtist.Add itm, artist
      End If
      If albumArtist <> "" And albumArtist <> itm.albumArtistName Then
         holdAlbumArtist.Add itm, albumArtist
      End If
      If title <> "" And title <> itm.title Then
         holdTitle.Add itm, title
      End If
      If album <> "" And album <> itm.albumName Then
         holdAlbum.Add itm, album
      End If
      doc.write "      </tr>" & vbCrLf
       
   Next 'i
    
   doc.write "    </table>" & vbCrLf
   doc.write "  </body>" & vbCrLf
   doc.write "</html>" & vbCrLf
   doc.Close
   SDB.Objects("holdArtist") = holdArtist
   SDB.Objects("holdAlbumArtist") = holdAlbumArtist
   SDB.Objects("holdAlbum") = holdAlbum
   SDB.Objects("holdTitle") = holdTitle
End Sub

Sub TitleCaseUpper()
   Dim UI, Form, Foot, Btn, Btn2, WB, doc
    
   Dim trackList
   Dim writeChanges

   Set trackList = SDB.SelectedSongList
   If trackList.Count = 0 Then
      Set trackList = SDB.AllVisibleSongList
   End If

   If trackList.Count = 0 Then
      res = SDB.MessageBox("Select tracks to be updated", mtError, Array(mbOk))
      Exit Sub
   End If


   Set UI = SDB.UI

   ' Create the window to be shown
   Set Form = UI.NewForm
   Form.Common.SetRect 50, 50, 500, 400
   Form.Common.MinWidth = 200
   Form.Common.MinHeight = 150
   Form.FormPosition = mmFormScreenCenter
   Form.SavePositionName = "CaseWindow"
   Form.Caption = SDB.Localize("Changes to Case")
   Form.StayOnTop = True

   ' Create a panel at the bottom of the window
   Set Foot = UI.NewPanel(Form)
   Foot.Common.Align = mmAlignBottom
   Foot.Common.Height = 35

   ' Create a button that closes the window
   Set Btn = UI.NewButton(Foot)
   Btn.Caption = SDB.Localize("&Cancel")
   Btn.Common.SetRect (Foot.Common.Width - 180) / 2 + 95, 9, 85, 24
'   Btn.Common.SetRect Foot.Common.Width - 90, 9, 85, 24
   'Btn.Common.Hint = SDB.Localize("Close this report")
   Btn.Common.Anchors = mmAnchorRight + mmAnchorBottom
   Btn.UseScript = Script.ScriptPath
   Btn.OnClickFunc = "OnCancel"

   ' Create a button that saves the report
   Set Btn2 = UI.NewButton(Foot)
   Btn2.Caption = SDB.Localize("&OK")
'   Btn2.Common.SetRect Foot.Common.Width - 90 - 5 - btn.common.width - 5, 9, 85, 24
   Btn2.Common.SetRect (Foot.Common.Width - 180) / 2, 9, 85, 24
   'Btn2.Common.Hint = SDB.Localize("Save this report")
   Btn2.Common.Anchors = mmAnchorRight + mmAnchorBottom
   Btn2.UseScript = Script.ScriptPath
   Btn2.OnClickFunc = "OnOK"

   ' Create a web browser component
   Set WB = UI.NewActiveX(Form, "Shell.Explorer")
   WB.Common.Align = mmAlignClient      ' Fill all client rectangle
   WB.Common.ControlName = "WB"
   WB.Interf.Navigate "about:"          ' A trick to make sure document exists
   Set doc = WB.Interf.Document

   Form.Common.Visible = True                ' Only show the form, don't wait for user input
   SDB.Objects("CaseThingy") = Form  ' Save reference to the form somewhere, otherwise it would simply disappear


   doc.write "<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.0 Transitional//EN"">" & vbCrLf
   doc.write "<html>" & vbCrLf
   doc.write "  <head>" & vbCrLf
   doc.write "    <title>" & SDB.Localize("Changes to Case") & "</title>" & vbCrLf
   doc.write "  </head>" & vbCrLf

   doc.write "<STYLE TYPE=text/css>" & vbCrLf
   doc.write "body{font-family:'Verdana',sans-serif; background-color:#FFFFFF; font-size:9pt; color:#000000;}" & vbCrLf
   doc.write "H1{font-family:'Verdana',sans-serif; font-size:13pt; font-weight:bold; color:#AAAAAA; text-align:left}" & vbCrLf
   doc.write "P{font-family:'Verdana',sans-serif; font-size:8pt; color:#000000;}" & vbCrLf
   doc.write "TH{font-family:'Verdana',sans-serif; font-size:9pt; font-weight:bold; color:#000000; border-color:#000000; border-style: 

solid; border-left-width:0px; border-right-width:0px; border-top-width:0px; border-bottom-width:3px;}" & vbCrLf
   doc.write "TD{font-family:'Verdana',sans-serif; font-size:8pt; color:#000000; border-color:#000000; border-style: solid; 

border-left-width:0px; border-right-width:0px; border-top-width:0px; border-bottom-width:1px;}" & vbCrLf
   doc.write "TD.highlight{font-family:'Verdana',sans-serif; font-size:8pt; background-color:#FFFF77; color:#000000; 

border-color:#000000; border-style: solid; border-left-width:0px; border-right-width:0px; border-top-width:0px; 

border-bottom-width:1px;}" & vbCrLf
   doc.write "TR.dark{background-color:#EEEEEE}" & vbCrLf
   doc.write "TR.aleft TH{text-align:left}" & vbCrLf
   doc.write "</STYLE>" & vbCrLf

   doc.write "  <body>" & vbCrLf
   doc.write "    <H1>" & SDB.Localize("Changes to Case:") & "</H1>" & vbCrLf
   doc.write "    <table border=""0"" cellspacing=""0"" cellpadding=""4"" width=""100%"">" & vbCrLf
'   doc.write "          <tr><th colspan=""4"">" & SDB.Localize(title) & "</th></tr>" & vbcrlf
   doc.write "      <tr class=""aleft"">" & vbCrLf
   doc.write "        <th>" & SDB.Localize("Artist") & "</th>" & vbCrLf
   doc.write "        <th>" & SDB.Localize("Title") & "</th>" & vbCrLf
   doc.write "        <th>" & SDB.Localize("Album") & "</th>" & vbCrLf
   doc.write "        <th>" & SDB.Localize("Album Artist") & "</th>" & vbCrLf
   doc.write "      </tr>" & vbCrLf

   Dim i, itm
   Dim artist, album, title, albumArtist
   For i = 0 To trackList.Count - 1
      doc.write "      <tr" & Style() & ">" & vbCrLf

      Set itm = trackList.Item(i)
      'artist = updateCase(itm.artistName)
      'title = updateCase(itm.title)
      'album = updateCase(itm.albumName)
      'albumArtist = updateCase(itm.albumArtistName)
      
      artist = UCase(itm.artistName)
      title = UCase(itm.title)
      album = UCase(itm.albumName)
      albumArtist = UCase(itm.albumArtistName)
      
      doc.write outField(artist, itm.artistName)
      doc.write outField(title, itm.title)
      doc.write outField(album, itm.albumName)
      doc.write outField(albumArtist, itm.albumArtistName)
      If artist <> "" And artist <> itm.artistName Then
         holdArtist.Add itm, artist
      End If
      If albumArtist <> "" And albumArtist <> itm.albumArtistName Then
         holdAlbumArtist.Add itm, albumArtist
      End If
      If title <> "" And title <> itm.title Then
         holdTitle.Add itm, title
      End If
      If album <> "" And album <> itm.albumName Then
         holdAlbum.Add itm, album
      End If
      doc.write "      </tr>" & vbCrLf
       
   Next 'i
    
   doc.write "    </table>" & vbCrLf
   doc.write "  </body>" & vbCrLf
   doc.write "</html>" & vbCrLf
   doc.Close
   SDB.Objects("holdArtist") = holdArtist
   SDB.Objects("holdAlbumArtist") = holdAlbumArtist
   SDB.Objects("holdAlbum") = holdAlbum
   SDB.Objects("holdTitle") = holdTitle
End Sub

Then, to make them visible in MM, edit the Scripts.ini file in "..\MediaMonkey\Scripts" by adding:

[TitleCaseL]
FileName=TitleCase.vbs
ProcName=TitleCaseLower
Order=19
DisplayName=Artist, Title, Album, Album Artist all lowercase
Description=Lowercase Artist, Title, Album, Album Artist
Language=VBScript
ScriptType=0

[TitleCaseU]
FileName=TitleCase.vbs
ProcName=TitleCaseUpper
Order=20
DisplayName=Artist, Title, Album, Album Artist all UPPERCASE
Description=UPPERCASE Artist, Title, Album, Album Artist
Language=VBScript
ScriptType=0

.. and save. Restart MM and enjoy.

No credits whatsoever, as all coding was originally done by Risser. The add-on was just to accomodate myself, but I thought maybe someone liked this function as well.

Regards,


Gerard - MrData
The Netherlands

judas
Posts: 572
Joined: Thu Jun 02, 2005 11:26 pm
Location: Bogotá, Colombia

Post by judas » Tue Jul 26, 2005 10:55 am

Thanks a lot MrData....I first put all in uppercase and then change the title and album fields to titlecase...i will see how to modify all that to addapt it to my needs :-) problem is that i have no idea of VB

at first i got some errors in the code due to it breaking in different lines...i now fixed it and its working perfectly.

here's the updated code: (hope copy and pasting now works!!)

Code: Select all

Sub TitleCaseLower() 
   Dim UI, Form, Foot, Btn, Btn2, WB, doc 
    
   Dim trackList 
   Dim writeChanges 

   Set trackList = SDB.SelectedSongList 
   If trackList.Count = 0 Then 
      Set trackList = SDB.AllVisibleSongList 
   End If 

   If trackList.Count = 0 Then 
      res = SDB.MessageBox("Select tracks to be updated", mtError, Array(mbOk)) 
      Exit Sub 
   End If 


   Set UI = SDB.UI 

   ' Create the window to be shown 
   Set Form = UI.NewForm 
   Form.Common.SetRect 50, 50, 500, 400 
   Form.Common.MinWidth = 200 
   Form.Common.MinHeight = 150 
   Form.FormPosition = mmFormScreenCenter 
   Form.SavePositionName = "CaseWindow" 
   Form.Caption = SDB.Localize("Changes to Case") 
   Form.StayOnTop = True 

   ' Create a panel at the bottom of the window 
   Set Foot = UI.NewPanel(Form) 
   Foot.Common.Align = mmAlignBottom 
   Foot.Common.Height = 35 

   ' Create a button that closes the window 
   Set Btn = UI.NewButton(Foot) 
   Btn.Caption = SDB.Localize("&Cancel") 
   Btn.Common.SetRect (Foot.Common.Width - 180) / 2 + 95, 9, 85, 24 
'   Btn.Common.SetRect Foot.Common.Width - 90, 9, 85, 24 
   'Btn.Common.Hint = SDB.Localize("Close this report") 
   Btn.Common.Anchors = mmAnchorRight + mmAnchorBottom 
   Btn.UseScript = Script.ScriptPath 
   Btn.OnClickFunc = "OnCancel" 

   ' Create a button that saves the report 
   Set Btn2 = UI.NewButton(Foot) 
   Btn2.Caption = SDB.Localize("&OK") 
'   Btn2.Common.SetRect Foot.Common.Width - 90 - 5 - btn.common.width - 5, 9, 85, 24 
   Btn2.Common.SetRect (Foot.Common.Width - 180) / 2, 9, 85, 24 
   'Btn2.Common.Hint = SDB.Localize("Save this report") 
   Btn2.Common.Anchors = mmAnchorRight + mmAnchorBottom 
   Btn2.UseScript = Script.ScriptPath 
   Btn2.OnClickFunc = "OnOK" 

   ' Create a web browser component 
   Set WB = UI.NewActiveX(Form, "Shell.Explorer") 
   WB.Common.Align = mmAlignClient      ' Fill all client rectangle 
   WB.Common.ControlName = "WB" 
   WB.Interf.Navigate "about:"          ' A trick to make sure document exists 
   Set doc = WB.Interf.Document 

   Form.Common.Visible = True                ' Only show the form, don't wait for user input 
   SDB.Objects("CaseThingy") = Form  ' Save reference to the form somewhere, otherwise it would simply disappear 


   doc.write "<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.0 Transitional//EN"">" & vbCrLf 
   doc.write "<html>" & vbCrLf 
   doc.write "  <head>" & vbCrLf 
   doc.write "    <title>" & SDB.Localize("Changes to Case") & "</title>" & vbCrLf 
   doc.write "  </head>" & vbCrLf 

   doc.write "<STYLE TYPE=text/css>" & vbCrLf 
   doc.write "body{font-family:'Verdana',sans-serif; background-color:#FFFFFF; font-size:9pt; color:#000000;}" & vbCrLf 
   doc.write "H1{font-family:'Verdana',sans-serif; font-size:13pt; font-weight:bold; color:#AAAAAA; text-align:left}" & vbCrLf 
   doc.write "P{font-family:'Verdana',sans-serif; font-size:8pt; color:#000000;}" & vbCrLf 
   doc.write "TH{font-family:'Verdana',sans-serif; font-size:9pt; font-weight:bold; color:#000000; border-color:#000000; border-style: solid; border-left-width:0px; border-right-width:0px; border-top-width:0px; border-bottom-width:3px;}" & vbCrLf 
   doc.write "TD{font-family:'Verdana',sans-serif; font-size:8pt; color:#000000; border-color:#000000; border-style: solid; border-left-width:0px; border-right-width:0px; border-top-width:0px; border-bottom-width:1px;}" & vbCrLf 
   doc.write "TD.highlight{font-family:'Verdana',sans-serif; font-size:8pt; background-color:#FFFF77; color:#000000; border-color:#000000; border-style: solid; border-left-width:0px; border-right-width:0px; border-top-width:0px; border-bottom-width:1px;}" & vbCrLf 
   doc.write "TR.dark{background-color:#EEEEEE}" & vbCrLf 
   doc.write "TR.aleft TH{text-align:left}" & vbCrLf 
   doc.write "</STYLE>" & vbCrLf 

   doc.write "  <body>" & vbCrLf 
   doc.write "    <H1>" & SDB.Localize("Changes to Case:") & "</H1>" & vbCrLf 
   doc.write "    <table border=""0"" cellspacing=""0"" cellpadding=""4"" width=""100%"">" & vbCrLf 
'   doc.write "          <tr><th colspan=""4"">" & SDB.Localize(title) & "</th></tr>" & vbcrlf 
   doc.write "      <tr class=""aleft"">" & vbCrLf 
   doc.write "        <th>" & SDB.Localize("Artist") & "</th>" & vbCrLf 
   doc.write "        <th>" & SDB.Localize("Title") & "</th>" & vbCrLf 
   doc.write "        <th>" & SDB.Localize("Album") & "</th>" & vbCrLf 
   doc.write "        <th>" & SDB.Localize("Album Artist") & "</th>" & vbCrLf 
   doc.write "      </tr>" & vbCrLf 

   Dim i, itm 
   Dim artist, album, title, albumArtist 
   For i = 0 To trackList.Count - 1 
      doc.write "      <tr" & Style() & ">" & vbCrLf 

      Set itm = trackList.Item(i) 
      artist = LCase(itm.artistName) 
      title = LCase(itm.title) 
      album = LCase(itm.albumName) 
      albumArtist = LCase(itm.albumArtistName) 
      
      doc.write outField(artist, itm.artistName) 
      doc.write outField(title, itm.title) 
      doc.write outField(album, itm.albumName) 
      doc.write outField(albumArtist, itm.albumArtistName) 
      If artist <> "" And artist <> itm.artistName Then 
         holdArtist.Add itm, artist 
      End If 
      If albumArtist <> "" And albumArtist <> itm.albumArtistName Then 
         holdAlbumArtist.Add itm, albumArtist 
      End If 
      If title <> "" And title <> itm.title Then 
         holdTitle.Add itm, title 
      End If 
      If album <> "" And album <> itm.albumName Then 
         holdAlbum.Add itm, album 
      End If 
      doc.write "      </tr>" & vbCrLf 
        
   Next 'i 
    
   doc.write "    </table>" & vbCrLf 
   doc.write "  </body>" & vbCrLf 
   doc.write "</html>" & vbCrLf 
   doc.Close 
   SDB.Objects("holdArtist") = holdArtist 
   SDB.Objects("holdAlbumArtist") = holdAlbumArtist 
   SDB.Objects("holdAlbum") = holdAlbum 
   SDB.Objects("holdTitle") = holdTitle 
End Sub 

Sub TitleCaseUpper() 
   Dim UI, Form, Foot, Btn, Btn2, WB, doc 
    
   Dim trackList 
   Dim writeChanges 

   Set trackList = SDB.SelectedSongList 
   If trackList.Count = 0 Then 
      Set trackList = SDB.AllVisibleSongList 
   End If 

   If trackList.Count = 0 Then 
      res = SDB.MessageBox("Select tracks to be updated", mtError, Array(mbOk)) 
      Exit Sub 
   End If 


   Set UI = SDB.UI 

   ' Create the window to be shown 
   Set Form = UI.NewForm 
   Form.Common.SetRect 50, 50, 500, 400 
   Form.Common.MinWidth = 200 
   Form.Common.MinHeight = 150 
   Form.FormPosition = mmFormScreenCenter 
   Form.SavePositionName = "CaseWindow" 
   Form.Caption = SDB.Localize("Changes to Case") 
   Form.StayOnTop = True 

   ' Create a panel at the bottom of the window 
   Set Foot = UI.NewPanel(Form) 
   Foot.Common.Align = mmAlignBottom 
   Foot.Common.Height = 35 

   ' Create a button that closes the window 
   Set Btn = UI.NewButton(Foot) 
   Btn.Caption = SDB.Localize("&Cancel") 
   Btn.Common.SetRect (Foot.Common.Width - 180) / 2 + 95, 9, 85, 24 
'   Btn.Common.SetRect Foot.Common.Width - 90, 9, 85, 24 
   'Btn.Common.Hint = SDB.Localize("Close this report") 
   Btn.Common.Anchors = mmAnchorRight + mmAnchorBottom 
   Btn.UseScript = Script.ScriptPath 
   Btn.OnClickFunc = "OnCancel" 

   ' Create a button that saves the report 
   Set Btn2 = UI.NewButton(Foot) 
   Btn2.Caption = SDB.Localize("&OK") 
'   Btn2.Common.SetRect Foot.Common.Width - 90 - 5 - btn.common.width - 5, 9, 85, 24 
   Btn2.Common.SetRect (Foot.Common.Width - 180) / 2, 9, 85, 24 
   'Btn2.Common.Hint = SDB.Localize("Save this report") 
   Btn2.Common.Anchors = mmAnchorRight + mmAnchorBottom 
   Btn2.UseScript = Script.ScriptPath 
   Btn2.OnClickFunc = "OnOK" 

   ' Create a web browser component 
   Set WB = UI.NewActiveX(Form, "Shell.Explorer") 
   WB.Common.Align = mmAlignClient      ' Fill all client rectangle 
   WB.Common.ControlName = "WB" 
   WB.Interf.Navigate "about:"          ' A trick to make sure document exists 
   Set doc = WB.Interf.Document 

   Form.Common.Visible = True                ' Only show the form, don't wait for user input 
   SDB.Objects("CaseThingy") = Form  ' Save reference to the form somewhere, otherwise it would simply disappear 


   doc.write "<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.0 Transitional//EN"">" & vbCrLf 
   doc.write "<html>" & vbCrLf 
   doc.write "  <head>" & vbCrLf 
   doc.write "    <title>" & SDB.Localize("Changes to Case") & "</title>" & vbCrLf 
   doc.write "  </head>" & vbCrLf 

   doc.write "<STYLE TYPE=text/css>" & vbCrLf 
   doc.write "body{font-family:'Verdana',sans-serif; background-color:#FFFFFF; font-size:9pt; color:#000000;}" & vbCrLf 
   doc.write "H1{font-family:'Verdana',sans-serif; font-size:13pt; font-weight:bold; color:#AAAAAA; text-align:left}" & vbCrLf 
   doc.write "P{font-family:'Verdana',sans-serif; font-size:8pt; color:#000000;}" & vbCrLf 
   doc.write "TH{font-family:'Verdana',sans-serif; font-size:9pt; font-weight:bold; color:#000000; border-color:#000000; border-style: solid; border-left-width:0px; border-right-width:0px; border-top-width:0px; border-bottom-width:3px;}" & vbCrLf 
   doc.write "TD{font-family:'Verdana',sans-serif; font-size:8pt; color:#000000; border-color:#000000; border-style: solid; border-left-width:0px; border-right-width:0px; border-top-width:0px; border-bottom-width:1px;}" & vbCrLf 
   doc.write "TD.highlight{font-family:'Verdana',sans-serif; font-size:8pt; background-color:#FFFF77; color:#000000; border-color:#000000; border-style: solid; border-left-width:0px; border-right-width:0px; border-top-width:0px; border-bottom-width:1px;}" & vbCrLf 
   doc.write "TR.dark{background-color:#EEEEEE}" & vbCrLf 
   doc.write "TR.aleft TH{text-align:left}" & vbCrLf 
   doc.write "</STYLE>" & vbCrLf 

   doc.write "  <body>" & vbCrLf 
   doc.write "    <H1>" & SDB.Localize("Changes to Case:") & "</H1>" & vbCrLf 
   doc.write "    <table border=""0"" cellspacing=""0"" cellpadding=""4"" width=""100%"">" & vbCrLf 
'  doc.write "          <tr><th colspan=""4"">" & SDB.Localize(title) & "</th></tr>" & vbcrlf 
   doc.write "      <tr class=""aleft"">" & vbCrLf 
   doc.write "        <th>" & SDB.Localize("Artist") & "</th>" & vbCrLf 
   doc.write "        <th>" & SDB.Localize("Title") & "</th>" & vbCrLf 
   doc.write "        <th>" & SDB.Localize("Album") & "</th>" & vbCrLf 
   doc.write "        <th>" & SDB.Localize("Album Artist") & "</th>" & vbCrLf 
   doc.write "      </tr>" & vbCrLf 

   Dim i, itm 
   Dim artist, album, title, albumArtist 
   For i = 0 To trackList.Count - 1 
      doc.write "      <tr" & Style() & ">" & vbCrLf 

      Set itm = trackList.Item(i) 
      'artist = updateCase(itm.artistName) 
      'title = updateCase(itm.title) 
      'album = updateCase(itm.albumName) 
      'albumArtist = updateCase(itm.albumArtistName) 
      
      artist = UCase(itm.artistName) 
      title = UCase(itm.title) 
      album = UCase(itm.albumName) 
      albumArtist = UCase(itm.albumArtistName) 
      
      doc.write outField(artist, itm.artistName) 
      doc.write outField(title, itm.title) 
      doc.write outField(album, itm.albumName) 
      doc.write outField(albumArtist, itm.albumArtistName) 
      If artist <> "" And artist <> itm.artistName Then 
         holdArtist.Add itm, artist 
      End If 
      If albumArtist <> "" And albumArtist <> itm.albumArtistName Then 
         holdAlbumArtist.Add itm, albumArtist 
      End If 
      If title <> "" And title <> itm.title Then 
         holdTitle.Add itm, title 
      End If 
      If album <> "" And album <> itm.albumName Then 
         holdAlbum.Add itm, album 
      End If 
      doc.write "      </tr>" & vbCrLf 
        
   Next 'i 
    
   doc.write "    </table>" & vbCrLf 
   doc.write "  </body>" & vbCrLf 
   doc.write "</html>" & vbCrLf 
   doc.Close 
   SDB.Objects("holdArtist") = holdArtist 
   SDB.Objects("holdAlbumArtist") = holdAlbumArtist 
   SDB.Objects("holdAlbum") = holdAlbum 
   SDB.Objects("holdTitle") = holdTitle 
End Sub

judas
Posts: 572
Joined: Thu Jun 02, 2005 11:26 pm
Location: Bogotá, Colombia

Post by judas » Tue Jul 26, 2005 11:24 am

:D Now I Got What I Need :D

i just did this in the UPPERCASE script:

Originally it was:

Code: Select all


      Set itm = trackList.Item(i) 
      'artist = updateCase(itm.artistName) 
      'title = updateCase(itm.title) 
      'album = updateCase(itm.albumName) 
      'albumArtist = updateCase(itm.albumArtistName) 
      
      artist = UCase(itm.artistName) 
      title = UCase(itm.title) 
      album = UCase(itm.albumName) 
      albumArtist = UCase(itm.albumArtistName)
and now i have:

Code: Select all

      Set itm = trackList.Item(i) 
      'artist = updateCase(itm.artistName) 
      title = updateCase(itm.title) 
      album = updateCase(itm.albumName) 
      'albumArtist = updateCase(itm.albumArtistName) 
      
      artist = UCase(itm.artistName) 
      'title = UCase(itm.title) 
      'album = UCase(itm.albumName) 
      albumArtist = UCase(itm.albumArtistName)
so there it is...now i get ARTIST and ALBUM ARTIST in UPPERCASE and Album and Title in, well...Title Case :D


thanks a lot for that post MrData...i was needing this for so long.

gtbuzz
Posts: 129
Joined: Mon Jul 18, 2005 11:09 am
Contact:

Post by gtbuzz » Wed Jul 27, 2005 8:53 am

Great script. What I'd really like to see an option to automatically remove 'The', 'A', and 'An' from the beginning for all the fields.

judas
Posts: 572
Joined: Thu Jun 02, 2005 11:26 pm
Location: Bogotá, Colombia

Post by judas » Wed Jul 27, 2005 9:02 am

this might be what you're looking for...puts those words last...check it out.

http://www.mediamonkey.com/forum/viewtopic.php?t=1478

gtbuzz
Posts: 129
Joined: Mon Jul 18, 2005 11:09 am
Contact:

Post by gtbuzz » Wed Jul 27, 2005 9:09 am

I've seen that one. I may be able to figure out enough VBScript to get it working for what I want. I just want those 3 words completely removed if they start a field. Thought it would be nice to only have 1 script to run. I'll see what I can do next weekend.

caveman
Posts: 4
Joined: Thu Oct 13, 2005 2:37 pm

requesting some help

Post by caveman » Wed Oct 19, 2005 3:37 pm

Nice job Risser! I dig your script.

I'm just wondering if there is a way to add a checkbox to the accept or cancel modifications page, so that one could optionally select files to modify?

Thanks.

Post Reply