You have to save the following code as: PlayCounter.vbs
Code: Select all
Sub ChangePlayCounter
' Define variables
Dim list, itm, i, newPlayCounter, mb, progress
'Get a new value for the Play Counter from the user
newPlayCounter = InputBox("Enter the new value for the Played field", "Modify Play Counter")
'If Canceled, exit
If newPlayCounter = "" Then
Exit Sub
End If
'Check that the text entered is a valid parameter. Inform user if it isn't.
If Not IsNumeric(newPlayCounter) Then
mb = MsgBox("You did not enter a number. Please try again.",0,"Error")
Exit Sub
ElseIf newPlayCounter < 0 Then
mb = MsgBox("Only positive numbers or 0 are allowed. Please try again.",0,"Error")
Exit Sub
End If
' Get list of selected tracks from MediaMonkey
Set list = SDB.SelectedSongList
If list.count=0 Then
Set list = SDB.AllVisibleSongList
End If
'No songs selected?
If list.count = 0 Then
mb = MsgBox("No songs were selected. Please select some songs and try again",0,"Error")
Exit Sub
End If
'Set up progress
Set Progress = SDB.Progress
Progress.Text = "Changing Play Counters..."
Progress.MaxValue = list.count
'Process all selected tracks
For i=0 To list.count-1
Set itm = list.Item(i)
'Set the Play Counter
itm.PlayCounter = newPlayCounter
itm.UpdateDB
Progress.value = i+1
If Progress.terminate Then
Exit For
End if
Next
Set Progress = nothing
End Sub
Sub ResetPlayCounter
'This is drastic, so require confirmation from user
Dim yesimsure
yesimsure = InputBox("Are you sure you want to reset the play counter for all tracks in the Library? Write YES to proceed.", "Reset Play Counter")
If yesimsure <> "YES" Then
Exit Sub
End If
'Reset the counter...
SDB.Database.ExecSQL("UPDATE SONGS SET PLAYCOUNTER = 0 WHERE TRUE=TRUE")
End Sub
Sub RestorePlayCounter
Dim mb
mb = MsgBox("This script has not been implemented yet.")
End Sub
Code: Select all
[ChangePlayCounter]
FileName=PlayCounter.vbs
ProcName=ChangePlayCounter
Order=20
DisplayName=Change Play Counter
Description=Change the play counter of the selected files
Language=VBScript
ScriptType=0
[ResetPlayCounter]
FileName=PlayCounter.vbs
ProcName=ResetPlayCounter
Order=21
DisplayName=Reset Play Counter
Description=Reset the play counter of all files in the library
Language=VBScript
ScriptType=0
Pablo