by Edgar » Mon Jun 19, 2017 11:42 am
I've written a custom script which has quite a bit of code. When I run it on a large number of files it would be nice to know how things are progressing. At a bare minimum it would be nice to know when the script terminates. Is there any way to add a progress bar to a custom script? Barring that, is there any way to give an audible notification (play a short sound file, TTSPlayString etc.) as the last action of a script?
I found a script to copy from; here's an example:
[code]' A script to eliminate unnecessary spaces; with progress bar
Option Explicit
Sub Trivial
' Define variables
Dim list, song, i, temp
Dim Progress, ExpText
Set Progress = SDB.Progress
ExpText = "Eliminating excess spaces..."
Progress.Text = ExpText
' Get list of selected tracks from MediaMonkey
Set list = SDB.SelectedSongList
If list.count=0 Then
Set list = SDB.AllVisibleSongList
End If
Progress.MaxValue = list.count
' Process all selected tracks
For i = 0 To list.count - 1
Set song = list.Item(i)
temp = song.Title
Progress.Text = ExpText & " (" & song.Title & ")"
temp = Replace(temp, "( .)", ".")
temp = Trim(temp)' remove leading and trailing spaces
For j = 1 To 10
temp = Replace(temp, " ", " ")' remove double spaces
Next
song.Title = temp
temp = song.ArtistName
temp = Replace(temp, "( .)", ".")
temp = Trim(temp)
For j = 1 To 10
temp = Replace(temp, " ", " ")
Next
song.ArtistName = temp
temp = song.AlbumArtistName
temp = Replace(temp, "( .)", ".")
temp = Trim(temp)
For j = 1 To 10
temp = Replace(temp, " ", " ")
Next
song.AlbumArtistName = temp
temp = song.AlbumName
temp = Replace(temp, "( .)", ".")
temp = Trim(temp)
For j = 1 To 10
temp = Replace(temp, " ", " ")
Next
song.AlbumName = temp
' Update the changes in DB
song.UpdateDB
Progress.Value = i+1
Next
End Sub
[/code]
I've written a custom script which has quite a bit of code. When I run it on a large number of files it would be nice to know how things are progressing. At a bare minimum it would be nice to know when the script terminates. Is there any way to add a progress bar to a custom script? Barring that, is there any way to give an audible notification (play a short sound file, TTSPlayString etc.) as the last action of a script?
I found a script to copy from; here's an example:
[code]' A script to eliminate unnecessary spaces; with progress bar
Option Explicit
Sub Trivial
' Define variables
Dim list, song, i, temp
Dim Progress, ExpText
Set Progress = SDB.Progress
ExpText = "Eliminating excess spaces..."
Progress.Text = ExpText
' Get list of selected tracks from MediaMonkey
Set list = SDB.SelectedSongList
If list.count=0 Then
Set list = SDB.AllVisibleSongList
End If
Progress.MaxValue = list.count
' Process all selected tracks
For i = 0 To list.count - 1
Set song = list.Item(i)
temp = song.Title
Progress.Text = ExpText & " (" & song.Title & ")"
temp = Replace(temp, "( .)", ".")
temp = Trim(temp)' remove leading and trailing spaces
For j = 1 To 10
temp = Replace(temp, " ", " ")' remove double spaces
Next
song.Title = temp
temp = song.ArtistName
temp = Replace(temp, "( .)", ".")
temp = Trim(temp)
For j = 1 To 10
temp = Replace(temp, " ", " ")
Next
song.ArtistName = temp
temp = song.AlbumArtistName
temp = Replace(temp, "( .)", ".")
temp = Trim(temp)
For j = 1 To 10
temp = Replace(temp, " ", " ")
Next
song.AlbumArtistName = temp
temp = song.AlbumName
temp = Replace(temp, "( .)", ".")
temp = Trim(temp)
For j = 1 To 10
temp = Replace(temp, " ", " ")
Next
song.AlbumName = temp
' Update the changes in DB
song.UpdateDB
Progress.Value = i+1
Next
End Sub
[/code]