This script is useful when clearing out a field for a large number of tracks as it works in the background.
The installers are available from my website.

Code: Select all
'
' MediaMonkey Script
'
' NAME: ClearField 1.3
'
' AUTHOR: trixmoto (http://trixmoto.net)
' DATE : 26/07/2014
'
' Thanks to Steegy for the SkinnedInputBox
'
' INSTALL: Copy to Scripts directory and add the following to Scripts.ini
' Don't forget to remove comments (') and set the order appropriately
'
' [ClearField]
' FileName=ClearField.vbs
' ProcName=ClearField
' Order=50
' DisplayName=&Clear Field
' Description=Clear field for selected tracks
' Language=VBScript
' ScriptType=0
'
' FIXES: Added dropdown list of fields available
' Fixed special case for Leveling and LevelingAlbum was case sensitive
'
Option Explicit
Sub ClearField
'get selected tracks
Dim list : Set list = SDB.SelectedSongList
If list.count = 0 Then
Set list = SDB.AllVisibleSongList
End If
If list.count = 0 Then
Call SDB.MessageBox("ClearField: There are no selected tracks.",mtError,Array(mbOk))
Exit Sub
End If
'get field name
Dim data : data = "text"
Dim flds : flds = "Actors~|~AlbumArtistName~|~AlbumName~|~ArtistName~|~Author~|~Band~|~Bitrate~|~Bookmark~|~BPM"
flds = flds&"~|~Cached~|~CachedPath~|~Channels~|~Comment~|~Conductor~|~Copyright~|~Custom1~|~Custom2~|~Custom3~|~Custom4~|~Custom5"
flds = flds&"~|~Date~|~DateAdded~|~DateDBModified~|~Day~|~DiscNumber~|~DiscNumberStr~|~Director"
flds = flds&"~|~Encoder~|~EpisodeNumber~|~FileLength~|~FileModified~|~GaplessBytes~|~Genre~|~Grouping~|~InvolvedPeople~|~ISRC"
flds = flds&"~|~LastPlayed~|~Leveling~|~LevelingAlbum~|~Lyricist~|~Lyrics"
flds = flds&"~|~MarkPlayed~|~Media~|~MediaLabel~|~Month~|~Mood~|~MusicComposer"
flds = flds&"~|~Occasion~|~OriginalArtist~|~OriginalLyricist~|~OriginalTitle~|~OriginalYear~|~OriginalMonth~|~OriginalDay"
flds = flds&"~|~ParentalRating~|~Path~|~PeakValue~|~PlayCounter~|~PostGap~|~PreGap~|~Preview~|~PreviewPath~|~Producer~|~Publisher"
flds = flds&"~|~Quality~|~Rating~|~RatingString"
flds = flds&"~|~SampleRate~|~SeasonNumber~|~Series~|~SetPathByMask~|~SkipCount~|~SongLength~|~SongLengthString~|~StartTime~|~StopTime"
flds = flds&"~|~Tempo~|~Title~|~TotalSamples~|~TrackOrder~|~TrackOrderString~|~TrackType~|~VBR~|~Year~|~(Other)"
Dim temp : temp = SDB.IniFile.StringValue("Scripts","ClearField")
Dim name : name = SkinnedDropdown("Please select a field:","ClearField",flds,temp,"ClearField")
If name = "" Or name = "(Other)" Then
name = SkinnedInputBox("Please enter field name:","ClearField",temp,"ClearField")
End If
SDB.IniFile.StringValue("Scripts","ClearField") = name
'check field name
If name = "" Then
Call SDB.MessageBox("ClearField: No field name was specified.",mtError,Array(mbOk))
Exit Sub
Else
On Error Resume Next
Execute("temp = list.Item(0)."&name)
If Err.Number <> 0 Then
Err.Clear
Call SDB.MessageBox("ClearField: Invalid field name was specified.",mtError,Array(mbOk))
Exit Sub
End If
Execute("list.Item(0)."&name&" = """"")
If Err.Number <> 0 Then
Err.Clear
data = "numeric"
Else
Execute("list.Item(0)."&name&" = temp")
End If
On Error Goto 0
End If
'create progress bar
Dim prog : Set prog = SDB.Progress
prog.Value = 0
prog.MaxValue = list.Count
prog.Text = "ClearField: Awaiting user confirmation..."
'get confirmation
Dim s : s = "ClearField: Clear "&data&" field '"&name&"' from "&list.Count&" tracks?"
Dim i : i = SDB.MessageBox(s,mtConfirmation,Array(mbYes,mbNo))
If Not (i = mrYes) Then
Exit Sub
End If
'process tracks
For i = 0 To list.Count-1
prog.Text = "ClearField: Processing track "&(i+1)&" of "&(list.Count)&"..."
SDB.ProcessMessages
If data = "text" Then
Execute("list.Item(i)."&name&" = """"")
Else
If (UCase(name) = "LEVELING") Or (UCase(name) = "LEVELINGALBUM") Then
Execute("list.Item(i)."&name&" = -999999")
Else
Execute("list.Item(i)."&name&" = -1")
End if
End If
Dim l : Set l = SDB.NewSongList
Call l.Add(list.Item(i))
Call l.UpdateAll()
prog.Increase
If prog.Terminate Then
Exit Sub
End If
Next
End Sub
Function SkinnedInputBox(Text, Caption, Input, PositionName)
Dim Form, Label, Edt, btnOk, btnCancel, modalResult
' Create the window to be shown
Set Form = SDB.UI.NewForm
Form.Common.SetRect 100, 100, 360, 130
Form.BorderStyle = 2 ' Resizable
Form.FormPosition = 4 ' Screen Center
Form.SavePositionName = PositionName
Form.Caption = Caption
' Create a button that closes the window
Set Label = SDB.UI.NewLabel(Form)
Label.Caption = Text
Label.Common.Left = 5
Label.Common.Top = 10
Set Edt = SDB.UI.NewEdit(Form)
Edt.Common.Left = Label.Common.Left
Edt.Common.Top = Label.Common.Top + Label.Common.Height + 5
Edt.Common.Width = Form.Common.Width - 25
Edt.Common.ControlName = "Edit1"
Edt.Common.Anchors = 1+2+4 'Left+Top+Right
Edt.Text = Input
' Create a button that closes the window
Set BtnOk = SDB.UI.NewButton(Form)
BtnOk.Caption = "&OK"
BtnOk.Common.Top = Edt.Common.Top + Edt.Common.Height + 10
BtnOk.Common.Hint = "OK"
BtnOk.Common.Anchors = 4 ' Right
BtnOk.UseScript = Script.ScriptPath
BtnOk.Default = True
BtnOk.ModalResult = 1
Set BtnCancel = SDB.UI.NewButton(Form)
BtnCancel.Caption = "&Cancel"
BtnCancel.Common.Left = Form.Common.Width - BtnCancel.Common.Width - 15
BtnOK.Common.Left = BtnCancel.Common.Left - BtnOK.Common.Width - 10
BtnCancel.Common.Top = BtnOK.Common.Top
BtnCancel.Common.Hint = "Cancel"
BtnCancel.Common.Anchors = 4 ' Right
BtnCancel.UseScript = Script.ScriptPath
BtnCancel.Cancel = True
BtnCancel.ModalResult = 2
If Form.showModal = 1 Then
SkinnedInputBox = Edt.Text
Else
SkinnedInputBox = ""
End If
End Function
Function SkinnedDropdown(Text,Caption,flds,temp,PositionName)
Dim Form, Label, Edt, btnOk, btnCancel, modalResult
' Create the window to be shown
Set Form = SDB.UI.NewForm
Form.Common.SetRect 100, 100, 360, 130
Form.BorderStyle = 4 ' Resizable
Form.FormPosition = 4 ' Screen Center
Form.SavePositionName = PositionName
Form.Caption = Caption
' Create a button that closes the window
Set Label = SDB.UI.NewLabel(Form)
Label.Caption = Text
Label.Common.Left = 5
Label.Common.Top = 10
Set Edt = SDB.UI.NewDropDown(Form)
Edt.Common.Left = Label.Common.Left
Edt.Common.Top = Label.Common.Top + Label.Common.Height + 5
Edt.Common.Width = Form.Common.Width - 25
Edt.Common.ControlName = "Edit1"
Edt.Common.Anchors = 1+2+4 'Left+Top+Right
Call Edt.AddItem("Please select...")
Edt.ItemIndex = 0
Dim arr : arr = Split(flds,"~|~")
Dim i : i = 0
For i = 0 To UBound(arr)
Dim fld : fld = arr(i)
Call Edt.AddItem(fld)
If fld = temp Then
Edt.ItemIndex = i+1
End If
Next
' Create a button that closes the window
Set BtnOk = SDB.UI.NewButton(Form)
BtnOk.Caption = "OK"
BtnOk.Common.Top = Edt.Common.Top + Edt.Common.Height + 10
BtnOk.Common.Hint = "OK"
BtnOk.Common.Anchors = 4 ' Right
BtnOk.UseScript = Script.ScriptPath
BtnOk.Default = True
BtnOk.ModalResult = 1
Set BtnCancel = SDB.UI.NewButton(Form)
BtnCancel.Caption = "Cancel"
BtnCancel.Common.Left = Form.Common.Width - BtnCancel.Common.Width - 15
BtnOK.Common.Left = BtnCancel.Common.Left - BtnOK.Common.Width - 10
BtnCancel.Common.Top = BtnOK.Common.Top
BtnCancel.Common.Hint = "Cancel"
BtnCancel.Common.Anchors = 4 ' Right
BtnCancel.UseScript = Script.ScriptPath
BtnCancel.Cancel = True
BtnCancel.ModalResult = 2
SkinnedDropdown = ""
If Form.showModal = 1 Then
Dim nam : nam = Edt.SelText
If nam <> "Please select..." Then
SkinnedDropdown = nam
End If
End If
End Function
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("ClearField","Filename") = "ClearField.vbs"
inif.StringValue("ClearField","Procname") = "ClearField"
inif.StringValue("ClearField","Order") = "50"
inif.StringValue("ClearField","DisplayName") = "&Clear Field"
inif.StringValue("ClearField","Description") = "Clear field for selected tracks"
inif.StringValue("ClearField","Language") = "VBScript"
inif.StringValue("ClearField","ScriptType") = "0"
SDB.RefreshScriptItems
End If
End Sub