Showing "Track #" metadata in Custom field?

Get answers about using MediaMonkey 4 for Windows.

Moderator: Gurus

chyron8472
Posts: 6
Joined: Mon Apr 22, 2013 2:41 pm

Showing "Track #" metadata in Custom field?

Post by chyron8472 »

Hi There.

I'm a new convert to MedaMonkey, coming over from WinAmp. (I initially came to MM while looking to help a coworker find an alternative to iTunes for music, as she has an iPhone, and I'm going nuts for MM Gold's customization abilities).

For the most part, I've been able to figure out quite a bit about how to get MM to do what I want it to.

However, I would rather the heading of the "Track #" column just said "#". I am aware that only the Custom fields can have their headings edited, so my plan is to rename one of the Custom headlngs to "#" (I know how to do that part) and to have said field show the metadata from the "Track #" field.

How do I get a custom field to show the "Track #" metadata?
Lowlander
Posts: 59391
Joined: Sat Sep 06, 2003 5:53 pm

Re: Showing "Track #" metadata in Custom field?

Post by Lowlander »

RegExp Find & Replace can copy tags from one to another field: http://www.mediamonkey.com/forum/viewto ... =2&t=28510
chyron8472
Posts: 6
Joined: Mon Apr 22, 2013 2:41 pm

Re: Showing "Track #" metadata in Custom field?

Post by chyron8472 »

Is there a way that this could be done on-the-fly (ie. automatically)? That plugin does work, but it only runs the script when I manually tell it to.
Lowlander
Posts: 59391
Joined: Sat Sep 06, 2003 5:53 pm

Re: Showing "Track #" metadata in Custom field?

Post by Lowlander »

I'm not aware of any auto-method.
chyron8472
Posts: 6
Joined: Mon Apr 22, 2013 2:41 pm

Re: Showing "Track #" metadata in Custom field?

Post by chyron8472 »

Well, the wiki does say how to have a script run each time on startup:
http://www.mediamonkey.com/wiki/index.p ... uto-script
But I don't need it to run on all files every time I open MM.

Is there a way to have a script automatically be performed on a file when I add it to the Library?
nohitter151
Posts: 23640
Joined: Wed Aug 09, 2006 10:20 am
Location: NJ, USA
Contact:

Re: Showing "Track #" metadata in Custom field?

Post by nohitter151 »

chyron8472 wrote:Well, the wiki does say how to have a script run each time on startup:
http://www.mediamonkey.com/wiki/index.p ... uto-script
But I don't need it to run on all files every time I open MM.

Is there a way to have a script automatically be performed on a file when I add it to the Library?
Yes, if you're looking for example code you could find it from this script: http://www.mediamonkey.com/forum/viewto ... 40#p300742
MediaMonkey user since 2006
Need help? Got a suggestion? Can't find something?

Please no PMs in reply to a post. Just reply in the thread.
chyron8472
Posts: 6
Joined: Mon Apr 22, 2013 2:41 pm

Re: Showing "Track #" metadata in Custom field?

Post by chyron8472 »

nohitter151 wrote:
chyron8472 wrote:Well, the wiki does say how to have a script run each time on startup:
http://www.mediamonkey.com/wiki/index.p ... uto-script
But I don't need it to run on all files every time I open MM.

Is there a way to have a script automatically be performed on a file when I add it to the Library?
Yes, if you're looking for example code you could find it from this script: http://www.mediamonkey.com/forum/viewto ... 40#p300742
So...

from the RegExpReplace.vbs, I found:

Code: Select all

Function RegSub(sExpr, sPattern, sReplace)
    Dim RE2

    Set RE2 = New RegExp
    RE2.Pattern = sPattern
    RE2.Global = True
    If bMatchCase Then
        RE2.IgnoreCase = False
    Else
        RE2.IgnoreCase = True
    End If
    RegSub = RE2.Replace(sExpr, sReplace)
End Function

"[...later in file]

"<td><code>RegSub(string, pattern, replace)</code></td>" & _
"<td>Performs substitution based on pattern matching. Preset example: ""Copy the Artist name to the Custom 3 field..."".</td>" & _
Which seems to me to be the code for manually doing what I want.

And the code for that CleanImport.vbs, which runs on adding a new track, is:

Code: Select all

Option Explicit

Const SCRIPT_NAME = "CleanImport"
Dim AllowCleaning
Dim OptionSheetID

Dim Fields
Dim EmptyValues
Dim ClearByDefault
Dim ClearByChoice

Sub OnStartup

    Fields = Array("Author", "Band", "Conductor", "InvolvedPeople", "Grouping", "Bookmark", "Genre", "Comment", "Lyrics", "Rating", "RatingString", "Tempo", "Quality", "Occasion", "Mood", "Publisher", "ISRC", "Encoder", "Copyright", "Lyricist", "OriginalLyricist")
    EmptyValues = Array("","","","","","0","","","","-1","","","","","","","","","","","")
    ClearByDefault = Array(True, True, True, True, True, True, False, True, False, True, True, True, True, True, True, True, True, True, True, True, True)
    
    ClearByChoice = ClearByDefault

    Dim i
    For i = 0 To UBound(Fields)
        If Not SDB.IniFile.ValueExists(SCRIPT_NAME, "Clear_" & Fields(i)) Then
            SDB.IniFile.BoolValue(SCRIPT_NAME, "Clear_" & Fields(i)) = ClearByDefault(i)
        Else
            ClearByChoice(i) = SDB.IniFile.BoolValue(SCRIPT_NAME, "Clear_" & Fields(i))
        End If
    Next
    
    If SDB.IniFile.BoolValue(SCRIPT_NAME, "AlwaysAllowCleaning") = True Then AllowCleaning = True
    
    Script.RegisterEvent SDB, "OnTrackAdded", "CleanImportedTags"
    
    OptionSheetID = SDB.UI.AddOptionSheet("CleanImport", Script.ScriptPath, "InitSheet1", "SaveSheet1", -3)

End Sub


Sub CleanImportedTags(NewTrack)

    Dim Msg
    Msg = "Allow the CleanImport script to clean out the tags specified in the options?" & vbNewLine & _
        vbNewLine & _
        "          Yes:  Yes for now. Ask me again next session." & vbNewLine & _
        "Yes To All:  Yes, and don't ask me again." & vbNewLine & _
        "            No:  No for now. Ask me again next session."

    If IsEmpty(AllowCleaning) Then

        Dim Result : Result = SDB.MessageBox(Msg, mtWarning, Array(mbYesToAll,mbYes,mbNo))
        If Result = mrYesToAll Then
            SDB.IniFile.BoolValue(SCRIPT_NAME, "AlwaysAllowCleaning") = True
            AllowCleaning = True
        ElseIf Result = mrYes Then
            AllowCleaning = True
        Else
            AllowCleaning = False
        End If
    End If
    
    If Not AllowCleaning Then Exit Sub

    Dim i
    For i = 0 To UBound(Fields)
        If ClearByChoice(i) Then Execute("NewTrack." & Fields(i) & " = """ & EmptyValues(i) & """")
    Next
    
    NewTrack.UpdateDB

End Sub


Sub InitSheet1(Sheet1)

    Dim Label1 : Set Label1 = SDB.UI.NewLabel(Sheet1)
    Label1.Common.SetRect 18,27,500,17
    Label1.Common.ControlName = "Label1"
    Label1.Caption = "When adding a new track to MediaMonkey, clear the following fields:"
    
    Dim i, chk, xpos, ypos
    xpos = 40
    ypos = 60
    For i = 0 To UBound(Fields)
        Set chk = SDB.UI.NewCheckBox(Sheet1)
        chk.Caption = Fields(i)
        chk.Checked = ClearByChoice(i)
        chk.Common.SetRect xpos,ypos,100,20
        chk.Common.ControlName = "Clear_" & Fields(i)
        ypos = ypos + 20
        If ypos > 300 Then
            ypos = 60
            xpos = xpos + 150
        End If
    Next
    
    Dim chk2
    Set chk2 = SDB.UI.NewCheckBox(Sheet1)
    chk2.Caption = "Ask confirmation before clearing the fields."
    chk2.Checked = IsEmpty(AllowCleaning)
    chk2.Common.SetRect 60,360,400,20
    chk2.Common.ControlName = "AskConfirmation"
    
End Sub


Sub SaveSheet1(Sheet1)

    Dim i
    For i = 0 To UBound(Fields)
        If Sheet1.Common.ChildControl("Clear_" & Fields(i)).Checked <> ClearByChoice(i) Then
            ClearByChoice(i) = Not ClearByChoice(i)
            SDB.IniFile.BoolValue(SCRIPT_NAME, "Clear_" & Fields(i)) = ClearByChoice(i)
        End If
    Next
    
    If Sheet1.Common.ChildControl("AskConfirmation").Checked Then
        AllowCleaning = Empty
        SDB.IniFile.BoolValue(SCRIPT_NAME, "AlwaysAllowCleaning") = False
    Else
        AllowCleaning = True
    End If
    
End Sub


Sub Uninstall

    DoCleanup
    
    Dim MsgDeleteSettings : MsgDeleteSettings = "Uninstalling " & SCRIPT_NAME & "." & vbNewLine & _
    											"Do you want to remove the settings as well?" & vbNewLine & _
                                                "If you click No, script settings will be left in MediaMonkey.ini"
                                                
    If (Not SDB.IniFile Is Nothing) and (MsgBox(MsgDeleteSettings, vbYesNo, SCRIPT_NAME) = vbYes) Then
       SDB.IniFile.DeleteSection(SCRIPT_NAME)
    End If

End Sub


Sub DoCleanup

    If IsEmpty(OptionSheetID) Then Exit Sub
    
    SDB.UI.DeleteOptionSheet OptionSheetID
    
    Script.UnRegisterAllEvents

End Sub

What do I pull out of that to get what I want? I'm not really that adept at coding.
Post Reply