It imports tags from a .txt file matching the track filename. The .txt file should contain tags in this format...
Code: Select all
Title=New Title
Comment=This is my comment
Code: Select all
'
' MediaMonkey Script
'
' NAME: TxtImporter 1.1
'
' AUTHOR: trixmoto (http://trixmoto.net)
' DATE : 27/02/2007
'
' INSTALL: Copy to Scripts directory and add the following to Scripts.ini
' Don't forget to remove comments (') and set the order appropriately
'
' FIXES: Added possibility of multiline tags
'
' [TxtImporter]
' FileName=TxtImporter.vbs
' ProcName=TxtImporter
' Order=30
' DisplayName=TxtImporter
' Description=Import tags from txt file
' Language=VBScript
' ScriptType=0
'
Option Explicit
Sub TxtImporter
'get list
Dim i : i = 0
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("Select tracks to be tagged.", mtError, Array(mbOk))
Exit Sub
Else
i = SDB.MessageBox("Import tags for "&list.Count&" tracks?", mtConfirmation, Array(mbYes,mbCancel))
If Not (i = mrYes) Then
Exit Sub
End If
End If
'progress bar
Dim fso : Set fso = CreateObject("Scripting.FileSystemObject")
Dim bar : Set bar = SDB.Progress
bar.MaxValue = list.Count
bar.Text = "TxtImporter: Initialising..."
'tag each track
For i = 0 To list.Count-1
'progress bar
bar.Text = "TxtImporter: Tagging track "&(i+1)&" of "&(list.Count)&"..."
bar.Increase
SDB.ProcessMessages
'get path of txt
Dim itm : Set itm = list.Item(i)
Dim path : path = Left(itm.Path,InStrRev(itm.Path,"."))&"txt"
If fso.FileExists(path) Then
'read file
Dim txt : Set txt = fso.OpenTextFile(path,1,False)
Dim pre,val,tag,str,pos
Do While Not txt.AtEndOfStream
str = Trim(txt.ReadLine)
pos = InStr(str,"=")
If pos > 0 Then
tag = Left(str,pos-1)
val = Mid(str,pos+1)
On Error Resume Next
Execute("itm."&tag&" = """&val&"""")
Err.Clear
On Error Goto 0
Else
If Not (tag = "") Then
On Error Resume Next
Execute("itm."&tag&" = itm."&tag&"&Chr(13)&"""&str&"""") '!
Err.Clear
On Error Goto 0
End If
End If
Loop
txt.close
Else
End If
If bar.Terminate Then Exit Sub
Next
'finish off
bar.Text = "TxtImporter: Finalising..."
SDB.ProcessMessages
list.UpdateAll
End Sub