Import XMCD 1.2 [MM2+3]
Posted: Wed Jun 13, 2007 12:44 pm
This is a script that has been requested...
As always, the installer is available from my website.
The script imports .xmcd files created by FreeDB, and creates the tracks within your MM library. For more details of the file format, see here.DazB wrote:I have local copies of the XMCD files (Unix flavoured) for my CD collection which I want to add to MM without physically inserting 2K+ discs
As always, the installer is available from my website.

Code: Select all
'
' MediaMonkey Script
'
' NAME: ImportXMCD 1.2
'
' AUTHOR: trixmoto (http://trixmoto.net)
' DATE : 02/09/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: Fixed track titles don't necessarily contain artist names
'
' [ImportXMCD]
' FileName=ImportXMCD.vbs
' ProcName=ImportXMCD
' Order=30
' DisplayName=Import XMCD
' Description=Import tags from xmcd file
' Language=VBScript
' ScriptType=0
'
Option Explicit
Sub ImportXMCD
'get filename
Dim dlg : Set dlg = SDB.CommonDialog
dlg.Filter = "XMCD file|*.*"
dlg.Flags = cdlOFNOverwritePrompt + cdlOFNHideReadOnly + cdlOFNNoChangeDir
dlg.InitDir = SDB.MyMusicPath
dlg.ShowOpen
If Not dlg.Ok Then
Exit Sub
End If
'read file
Dim alb : alb = ""
Dim art : art = ""
Dim yea : yea = ""
Dim gen : gen = ""
Dim tra : tra = 0
Dim fso : Set fso = CreateObject("Scripting.FileSystemObject")
Dim txt : Set txt = fso.OpenTextFile(dlg.FileName,1,False)
Do While Not txt.AtEndOfStream
Dim str : str = Trim(txt.ReadLine)
If Left(str,1) = "#" Then
'comment
Else
Dim pos : pos = InStr(str,"=")
If pos > 0 Then
Dim tag : tag = Left(str,pos-1)
Dim val : val = Mid(str,pos+1)
Select Case Left(tag,4)
Case "DTIT"
art = Left(val,InStr(val," / ")-1)
alb = Mid(val,InStr(val," / ")+3)
Case "DYEA"
yea = val
Case "DGEN"
gen = val
Case "TTIT"
tra = tra + 1
Dim itm : Set itm = SDB.NewSongData
itm.AlbumName = alb
itm.AlbumArtistName = art
itm.Year = yea
itm.Genre = gen
If InStr(val," / ") > 0 Then
itm.Title = Mid(val,InStr(val," / ")+3)
itm.ArtistName = Left(val,InStr(val," / ")-1)
Else
itm.Title = val
itm.ArtistName = art
End If
itm.TrackOrder = tra
itm.UpdateArtist
itm.UpdateAlbum
itm.UpdateDB
End Select
End If
End If
Loop
txt.close
Call SDB.MessageBox("ImportXMCD: "&tra&" tracks successfully created.",mtInformation,Array(mbOk))
End Sub