Code: Select all
' A script that edits the Artist of selected tracks and also assigns the album artist
Sub EditArtists
Const mmAnchorRight = 4
Const mmAnchorBottom = 8
Const mmAlignBottom = 2
Const mmFormScreenCenter = 4
Dim list, item, increment, temporary, amount, newName
Dim UI, MainWindow, Footer
Dim OKButton, CancelButton, TextField
Set UI = SDB.UI
Set MainWindow = UI.NewForm
MainWindow.Common.SetRect 500, 350, 500, 300
MainWindow.Common.MinWidth = 200
MainWindow.Common.MinHeight = 150
MainWindow.Caption = SDB.Localize("Enter a new artist name")
MainWindow.StayOnTop = True
'Set TextField = UI.NewTextBox
'TextField.Common.SetRect 20, 25, 485, 40
Set Footer = UI.NewPanel(MainWindow)
Footer.Common.Align = mmAlignBottom
Footer.Common.Height = 35
Set CancelButton = UI.NewButton(Footer)
CancelButton.Caption = SDB.Localize("&Cancel")
CancelButton.Common.SetRect dialogWidth - 106, 5, 85, 25
CancelButton.Common.Anchors = mmAnchorRight + mmAnchorBottom
CancelButton.Cancel = True
CancelButton.UseScript = Script.ScriptPath
CancelButton.OnClickFunc = "OnCancel"
Set OKButton = UI.NewButton(Footer)
OKButton.Caption = SDB.Localize("&OK")
OKButton.Common.SetRect dialogWidth - 306, 5, 85, 25
OKButton.Common.Anchors = mmAnchorRight + mmAnchorBottom
OKButton.Cancel = False
OKButton.UseScript = Script.ScriptPath
OKButton.OnClickFunc = "OnOK"
SDB.ProcessMessages
MainWindow.SavePositionName = "EditArtistNameWindow"
MainWindow.Common.Visible = True
SDB.Objects("Edit") = MainWindow
SDB.ProcessMessages
End Sub
Sub OnCancel(Btn)
SDB.Objects("Edit") = Nothing
End Sub
Sub OnOK(Btn)
' If TextField.Text <> "" Then
' RenameArtist (TextField.Text)
' Else
' Return
' End If
SDB.Objects("Edit") = Nothing
End Sub
Sub RenameArtist(pNewName)
Set list = SDB.CurrentSongList
amount = list.count - 1
For increment = 0 To amount
Set item = list.Item(increment)
item.ArtistName = pNewName
item.AlbumArtistName = pNewName
Next
list.UpdateAll
End Sub
Code: Select all
'Set TextField = UI.NewTextBox
'TextField.Common.SetRect 20, 25, 485, 40
Code: Select all
' If TextField.Text <> "" Then
' RenameArtist (TextField.Text)
' Else
' Return
' End If
Code: Select all
Sub RenameArtist(pNewName)
Set list = SDB.CurrentSongList
amount = list.count - 1
For increment = 0 To amount
Set item = list.Item(increment)
item.ArtistName = pNewName
item.AlbumArtistName = pNewName
Next
list.UpdateAll
End Sub
Thanks in advance for any help!