File List Export Error

Get answers about using MediaMonkey 4 for Windows.

Moderator: Gurus

coastalkid
Posts: 8
Joined: Sat Jan 21, 2012 1:51 pm

File List Export Error

Post by coastalkid »

Hi,

I am getting the follow error while trying to do a File List export. The duplicate reports work fine.

"Error #13 - Microsoft VBScript Runtime Error - Type Mismatch "MainExec" - File ....MediaMonkey/Scripts."

I running the latest version of MM4 on Windows 10.

Thanks,

Joe
Lowlander
Posts: 56574
Joined: Sat Sep 06, 2003 5:53 pm
Location: MediaMonkey 5

Re: File List Export Error

Post by Lowlander »

Which exact export are you running?
coastalkid
Posts: 8
Joined: Sat Jan 21, 2012 1:51 pm

Re: File List Export Error

Post by coastalkid »

File -> Create Reports -> File List. Once I select File List, I get the error.
Lowlander
Posts: 56574
Joined: Sat Sep 06, 2003 5:53 pm
Location: MediaMonkey 5

Re: File List Export Error

Post by Lowlander »

Try reinstalling the latest build: https://www.mediamonkey.com/forum/viewt ... 75#p472875

Which type of File List are you trying to export to, or do they all fail? Do you have any files selected when you try to use this feature?
coastalkid
Posts: 8
Joined: Sat Jan 21, 2012 1:51 pm

Re: File List Export Error

Post by coastalkid »

I re-installed the latest build. I am trying to do a File List export which is a .csv file. This is the only one that fails. I can do the other 2 types from the menu, which are "Duplicate Report" and "Duplicate Report - Previous Options".

I have tried highlighting files, artists, etc... but the error keeps happening.

I'm also getting this message after the original error when I cancel out of the error... "Error happened during script initialization."
Lowlander
Posts: 56574
Joined: Sat Sep 06, 2003 5:53 pm
Location: MediaMonkey 5

Re: File List Export Error

Post by Lowlander »

So File > Create Reports > File List (XML) works where File > Create Reports > File List (CSV) fails? It works here.
coastalkid
Posts: 8
Joined: Sat Jan 21, 2012 1:51 pm

Re: File List Export Error

Post by coastalkid »

I don't show the XML option, only the CSV.
yarguy
Posts: 394
Joined: Mon Apr 09, 2012 8:34 am

Re: File List Export Error

Post by yarguy »

What you say you see under File > Create Reports isn't what I see nor what I have ever seen. This is what that set of steps shows on my MM4

Just List Albums...
Statistics
File List (HTML)...
File List (XML)...
File List (CSV)...
File List (Excel)...
Custom Report...
Custom Report Auto...

I have been using MM4 for a long time and as far as I can remember those have always been the options for Create Reports. So I don't think this is the route you are taking. But for up-to-dateness, the version I am using is 4.1.30 Build1912. Exactly what steps are you using? Are you using a script rather than the built-in report function? To get what I think you want I would do:

1) Select files to be exported
2) Take the following steps: File > Create Reports > File List (CSV)
3) Enter the file name / folder / save
coastalkid
Posts: 8
Joined: Sat Jan 21, 2012 1:51 pm

Re: File List Export Error

Post by coastalkid »

Yeah, for some reason I don't have those options. Here is what is contained in my scripts folder. Is there something missing maybe?

C:\Users\coast\AppData\Roaming\MediaMonkey\Scripts

Auto - Folder (Contains other scripts)
ABackup - VB Script File
ABackup2 - VB Script File
AlbumArtTagger - VB Script File
ConvertJPEGtoBMP - Application
DuplicateReport - VB Script File
Scripts - Configuration Settings
UpdateLocationOfFiles - VB Script File
XZip.dll - Application Extension
yarguy
Posts: 394
Joined: Mon Apr 09, 2012 8:34 am

Re: File List Export Error

Post by yarguy »

It is not a script. Go to the File menu then choose Create Reports. Forget scripts. It is not a script. And if you insist on using a script you need to contact the developer of the script; use the Add-ons section of the Forum.

coastalkid wrote: Thu Sep 24, 2020 4:10 pm Yeah, for some reason I don't have those options. Here is what is contained in my scripts folder. Is there something missing maybe?

C:\Users\coast\AppData\Roaming\MediaMonkey\Scripts

Auto - Folder (Contains other scripts)
ABackup - VB Script File
ABackup2 - VB Script File
AlbumArtTagger - VB Script File
ConvertJPEGtoBMP - Application
DuplicateReport - VB Script File
Scripts - Configuration Settings
UpdateLocationOfFiles - VB Script File
XZip.dll - Application Extension
coastalkid
Posts: 8
Joined: Sat Jan 21, 2012 1:51 pm

Re: File List Export Error

Post by coastalkid »

I understand what the menu SHOULD look like. This is what MINE looks like:

Image

This is the error when I select File List (csv):

Image

Subsequent error when cancelling out of message (reference to SCRIPT):

Image
dtsig
Posts: 3588
Joined: Mon Jan 24, 2011 6:34 pm

Re: File List Export Error

Post by dtsig »

when you reinstalled .. did you download again?
Where's the db and ini stored
Reporting Bugs
Where tags are stored

Not affiliated with MediaMonkey ... just a RABID user/lover
DTSig
Lowlander
Posts: 56574
Joined: Sat Sep 06, 2003 5:53 pm
Location: MediaMonkey 5

Re: File List Export Error

Post by Lowlander »

You'll need this in scripts.ini in the MediaMonkey\Scripts folder as well as export.vbs (18KB) which has the functions for these different exporters.

Code: Select all

[ExportHTML]
FileName=Export.vbs
ProcName=ExportHTML
Order=2
DisplayName=File List (&HTML)
Description=Exports list of selected files to a .htm file
Language=VBScript
ScriptType=1

[ExportXML]
FileName=Export.vbs
ProcName=ExportXML
Order=3
DisplayName=File List (&XML)
Description=Exports list of selected files to an .xml file
Language=VBScript
ScriptType=1

[ExportCSV]
FileName=Export.vbs
ProcName=ExportCSV
Order=4
DisplayName=File List (CS&V)
Description=Exports list of selected files to a .csv file
Language=VBScript
ScriptType=1

[ExportXLS]
FileName=Export.vbs
ProcName=ExportXLS
Order=5
DisplayName=File List (&Excel)
Description=Exports list of selected files to a .xls file
Language=VBScript
ScriptType=1
coastalkid
Posts: 8
Joined: Sat Jan 21, 2012 1:51 pm

Re: File List Export Error

Post by coastalkid »

I made the update to the scripts.ini file. But I don't see an export.vbs file. And I've already reinstalled.
Lowlander
Posts: 56574
Joined: Sat Sep 06, 2003 5:53 pm
Location: MediaMonkey 5

Re: File List Export Error

Post by Lowlander »

Save the following to a file called export.vbs (you can do this with Notepad):

Code: Select all

' !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
' This file can be replaced  in one of the future versions,
' so please if you want to modify it, make  a copy, do your
' modifications  in that copy and  change Scripts.ini  file 
' appropriately. 
' If you do not do this, you will lose  all your changes in
' this script when you install a new version of MediaMonkey
' !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Option Explicit     ' report undefined variables, ...

' function for quoting strings
Function QStr( astr)
  QStr = chr(34) & astr & chr(34)
End Function

' function for quoting strings converted to plain ASCII
Function QAStr( astr)
  QAStr = chr(34) & SDB.toASCII(Replace(astr,"""","""""")) & chr(34)
End Function

Dim list      ' list of songs to be exported
Dim res       ' results of dialogs calls
Dim fullfile  ' fully specified output file name
Dim fso       ' FileSystemObject

' SDB variable is connected to MediaMonkey application object

Sub InitExport( ext, filter, iniDirValue)
  fullfile = ""

  ' Get a list of songs to be exported
  Set list = SDB.CurrentSongList

  If list.count=0 Then
    res = SDB.MessageBox( SDB.Localize("Select files to be exported, please."), mtError, Array(mbOk))
    Exit Sub
  End If

  ' Open inifile and get last used directory
  Dim iniF
  Set iniF = SDB.IniFile

  ' Create common dialog and ask where to save the file
  Dim dlg
  Set dlg = SDB.CommonDialog
  dlg.DefaultExt=ext
  dlg.Filter=filter
  dlg.Flags=cdlOFNOverwritePrompt + cdlOFNHideReadOnly + cdlOFNNoChangeDir
  dlg.InitDir = iniF.StringValue( "Scripts", iniDirValue)
  dlg.ShowSave

  if Not dlg.Ok Then
    Exit Sub   ' if cancel was pressed, exit
  End If

  ' Get the selected filename
  fullfile = dlg.FileName

  ' Connect to the FileSystemObject
  Set fso = SDB.Tools.FileSystem

  ' Write selected directory to the ini file
  iniF.StringValue( "Scripts", iniDirValue) = fullfile
End Sub

Function FormatStrTime (StrTimeValue)
  FormatStrTime = ""

  If Len (StrTimeValue) > 0 Then
    Dim BeginPosition, Position, TimePart, TimePartsCount
    BeginPosition = 1
    Position = InStr (BeginPosition, StrTimeValue, ":", vbTextCompare)
    TimePartsCount = 0

    Do While Position > 0
      TimePartsCount = TimePartsCount + 1
      BeginPosition = Position + 1
      Position = InStr (BeginPosition, StrTimeValue, ":", vbTextCompare)
    Loop

    For TimePart = 1 to 2 - TimePartsCount
      FormatStrTime = FormatStrTime + "00:"
    Next
  Else
    StrTimeValue = "00:00:00"
  End If

  FormatStrTime = FormatStrTime + StrTimeValue
  FormatStrTime = Replace (FormatStrTime, " ", "", 1, -1, vbTextCompare)
End Function

Sub FinishExport( ok)
  On Error Resume Next

  ' remove the output file if terminated
  if not Ok then
    fso.DeleteFile( fullfile)
  end if
End Sub

Sub ExportCSV
  ' initialize export
  Call InitExport (".csv", SDB.Localize("CSV (*.csv)|*.csv|All files (*.*)|*.*"), _
      "LastExportCSVDir")
  if fullfile="" then
    Exit Sub
  end if

  ' Create the output file
  Dim fout
  Set fout = fso.CreateTextFile( fullfile, True)

  ' Write header line
  fout.WriteLine Join(Array(SDB.Localize("Artist"),SDB.Localize("Title"), _
    SDB.Localize("Album"),SDB.Localize("Length"),SDB.Localize("Year"), _
    SDB.Localize("Genre"),SDB.Localize("Rating"),SDB.Localize("Bitrate"), _
    SDB.Localize("Path"),SDB.Localize("Media")),",")
 
  ' Use progress to notify user about the current action
  Dim Progress
  Set Progress = SDB.Progress
  Progress.Text = SDB.Localize("Exporting...")

  ' Iterate through the list and export all songs
  Progress.MaxValue = list.count
  Dim i, itm
  for i=0 to list.count-1
    Set itm = list.Item(i)
    Dim bitrate
    bitrate = itm.bitrate
    if bitrate>0 then
      bitrate = CStr(Round( bitrate/1000))
    else
      bitrate = ""
    end if
    fout.WriteLine Join( Array( QAStr(itm.ArtistName), QAStr(itm.title), QAStr(itm.AlbumName), _
      QAStr(FormatStrTime(itm.SongLengthString)), CStr(itm.Year), QAStr(itm.Genre), CStr(itm.Rating), CStr(bitrate), _
      QAStr(itm.Path), QAStr(itm.MediaLabel)), ",")
    Progress.Value = i+1
    if Progress.Terminate then
      Exit For
    end if
  next

  ' Close the output file and finish
  fout.Close

  ' Was it successfull?
  Dim ok
  if Progress.Terminate then
    ok = False
  else
    ok = True
  end if

  ' hide progress
  Set Progress = Nothing

  Call FinishExport( ok)
End Sub

 ' escape XML string
Function MapXML( srcstring)
  srcstring = Replace( srcstring, "&", "&")
  srcstring = Replace( srcstring, "<", "&lt;")
  srcstring = Replace( srcstring, ">", "&gt;")
  Dim i
  i=1
  While i<=Len(srcstring)
    If (AscW(Mid(srcstring, i, 1))>127) Then
      srcstring = Mid( srcstring, 1, i-1)+"&#"+CStr( AscW( Mid( srcstring, i, 1)))+";"+Mid( srcstring, i+1, Len(srcstring))
    End If
    i=i+1
  WEnd
  MapXML = srcstring
End Function

Sub ExportHTML 
  ' initialize export 
  Call InitExport( ".htm", SDB.Localize("HTML (*.htm)|*.htm|All files (*.*)|*.*"), _ 
  "LastExportHTMLDir") 
  if fullfile="" then 
  Exit Sub 
  end if 

  ' Create the output file 
  Dim fout 
  Set fout = fso.CreateTextFile( fullfile, True) 

  ' Write header line 
  fout.WriteLine "<!DOCTYPE html PUBLIC ""-//W3C//DTD XHTML 1.0 Transitional//EN"" ""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"">"
  fout.WriteLine "<html xmlns=""http://www.w3.org/1999/xhtml"">" 
  fout.WriteLine "<head><title>" & SDB.Localize("MediaMonkey Filelist") & "</title>" 

  ' Code to format the document 
  fout.WriteLine "<style type=""text/css"">" 
  fout.WriteLine "body{font-family:Verdana,Arial,Tahoma,sans-serif;background-color:#fff;font-size:small;color:#000;}" 
  fout.WriteLine "th{font-weight:bold;border-bottom:3px solid #000;}" 
  fout.WriteLine "td{color:#000;border-bottom:1px solid #000;padding:4px 6px;}"
  fout.WriteLine "tr.trhov:hover, tr.trhov:hover td{background-color:#ddd;}"
  fout.Writeline ".dark{background-color:#eee;}" 
  fout.WriteLine "</style>" 

  fout.WriteLine "</head><body>" 
  fout.WriteLine "<a href=""http://www.mediamonkey.com"" style=""font-size:1.4em;font-weight:bold;"">" & SDB.Localize("MediaMonkey Filelist")&"</a>" 

  ' Headers of table 
  fout.WriteLine "<br /><br /><table cellpadding=""4"" cellspacing=""0"">" 
  fout.WriteLine "<tr align=""left"">" 
  fout.WriteLine " <th class=""dark"">#</th>" 
  fout.WriteLine " <th>" & SDB.Localize("Artist") & "</th>" 
  fout.WriteLine " <th class=""dark"">" & SDB.Localize("Title") & "</th>" 
  fout.WriteLine " <th>" & SDB.Localize("Length") & "</th>" 
  fout.WriteLine " <th class=""dark"">" & SDB.Localize("Album") & "</th>" 
  fout.WriteLine " <th>" & SDB.Localize("Track #") & "</th>" 
  fout.WriteLine " <th class=""dark"">" & SDB.Localize("Year") & "</th>" 
  fout.WriteLine " <th>" & SDB.Localize("Genre") & "</th>" 
  fout.WriteLine " <th class=""dark"">" & SDB.Localize("Rating") & "</th>" 
  fout.WriteLine " <th>" & SDB.Localize("Bitrate") & "</th>" 
  fout.WriteLine " <th class=""dark"">" & SDB.Localize("Media") & "</th>" 
  fout.WriteLine "</tr>" 

  ' Use progress to notify user about the current action 
  Dim Progress 
  Set Progress = SDB.Progress 
  Progress.Text = SDB.Localize("Exporting...")

  ' Iterate through the list and export all songs 
  Progress.MaxValue = list.count 
  Dim i, itm, Duration, DurationHours
  DurationHours = 0
  for i=0 to list.count-1 
    Set itm = list.Item(i) 
    Dim bitrate 
    bitrate = itm.bitrate 
    if bitrate>0 then 
      bitrate = CStr(Round( bitrate/1000)) 
    else 
      bitrate = "&nbsp;" 
    end if 
    Dim year 
    year = itm.year 
    if year<=0 then 
      year = "&nbsp;" 
    else 
      year = CStr( year) 
    end if 

    ' Add space to empty fields, so table is displayed correctly (Cell borders do not show up for empty cells) 
    Dim artistname 
    artistname = MapXML(itm.ArtistName)
    if artistname="" then 
      artistname = "&nbsp;" 
    end if 

    Dim songtitle 
    songtitle = MapXML(itm.title)
    if songtitle="" then 
      songtitle = "&nbsp;" 
    end if 

    Dim albumname 
    albumname = MapXML(itm.AlbumName)
    if albumname="" then 
      albumname = "&nbsp;" 
    end if 

    Dim songlength
    songlength = itm.SongLengthString

    if songlength="" then 
      songlength = "&nbsp;" 
    else 
      Duration = Duration + TimeValue (FormatStrTime (songlength))
      if Hour(Duration) > 0 then
        DurationHours = DurationHours + 1
        Duration = Duration - TimeValue("01:00:00")
      end if
    end if

    Dim songgenre 
    songgenre = MapXML(itm.Genre)
    if songgenre="" then 
      songgenre = "&nbsp;" 
    end if 

    Dim trackorder 
    trackorder = itm.TrackOrder 
    if trackorder="" then 
      trackorder = "&nbsp;" 
    elseif trackorder = "0" then 
      trackorder = "&nbsp;" 
    end if 

    ' These are added to get some decent display, all the others haven't, this script is just to demonstrate all the available options 

    Dim rating 
    Dim ratingCal
    rating = itm.Rating 
    
    Select Case rating
  Case ""
    ratingCal = "&nbsp;"
  Case -1
    ratingCal = "&nbsp;"
  Case 100
    ratingCal = 5
  Case 90
    ratingCal = 4.5
  Case 80
    ratingCal = 4
  Case 70
    ratingCal = 3.5
  Case 60
    ratingCal = 3
  Case 50
    ratingCal = 2.5
  Case 40
    ratingCal = 2
  Case 30
    ratingCal = 1.5
  Case 20
    ratingCal = 1
  Case 10
    ratingCal = 0.5
  Case 0
    ratingCal = 0
  Case Else
    ratingCal = "&nbsp;"
    End Select
  
    Dim medialabel
    medialabel = MapXML(itm.MediaLabel)
    if medialabel="" then 
      medialabel = "&nbsp;" 
    end if

    ' Body of the table 
    fout.WriteLine "<tr class=""trhov""><td align=""right"" class=""dark"">"&i+1&"</td><td>"&artistname&"</td><td class=""dark"">"&songtitle _ 
    &"</td><td align=""right"">"&songlength&"</td><td class=""dark"">"&albumname _ 
    &"</td><td align=""right"">"&trackorder&"</td><td align=""right"" class=""dark"">"&Year _ 
    &"</td><td>"&songgenre&"</td><td class=""dark"">"&ratingCal&"</td><td align=""right"">"&bitrate _ 
    &"</td><td align=""right"" class=""dark"">"&medialabel&"</td></tr>" 
    Progress.Value = i+1 
    if Progress.Terminate then 
      Exit For 
    end if 
  next 

  ' Write some code to finish html document 
  fout.WriteLine "</table><table width=""100%""><tr>"
  fout.WriteLine "<td style=""border:none;""><b>"&SDB.Localize("Total Files:")&" </b>"&i&"</td>"
  fout.WriteLine "</tr><tr>"
  fout.WriteLine "<td style=""border:none;""><b>"&SDB.Localize("Duration:")&" </b>"&DurationHours& "h " &Minute (Duration)& "m " &Second (Duration)& "s</td>" 
  fout.WriteLine "<td align=""right"" style=""border:none;"">"&SDB.Localize("Generated by ")&"<a href=""http://www.mediamonkey.com"">MediaMonkey</a></td>"
  fout.WriteLine "</tr></table></body></html>"

  ' Close the output file and finish 
  fout.Close 

  ' Was it successfull? 
  Dim ok 
  if Progress.Terminate then 
    ok = False 
  else 
    ok = True 
  end if 

  ' hide progress 
  Set Progress = Nothing 

  FinishExport( ok) 
End Sub 

Sub ExportXLS
  ' initialize export
  Call InitExport( ".xls", SDB.Localize("Excel sheet (*.xls)|*.xls|All files (*.*)|*.*"), _
        "LastExportExcelDir")
  if fullfile="" then
    Exit Sub
  end if

  if fso.FileExists( fullfile) then
    fso.DeleteFile( fullfile)
  end if

  On Error Resume Next

  ' Connect to Excel
  Dim Excel, WB, WS
  Set Excel = CreateObject("Excel.application")

  If Err.Number<>0 then
    MsgBox SDB.Localize("Microsoft Excel could not be found, please install it and try again.")
    Err.Clear
    Exit Sub
  End If
  On Error GoTo 0

  ' Create a new workbook and get its worksheet
  Set WB = Excel.WorkBooks.Add
  Set WS = WB.Sheets(1)

  ' Use progress to notify user about the current action
  Dim Progress
  Set Progress = SDB.Progress
  Progress.Text = SDB.Localize("Exporting...")

  ' Create a header
  WS.Cells(1,1).Value = SDB.Localize("Artist")
  WS.Cells(1,2).Value = SDB.Localize("Album")
  WS.Cells(1,3).Value = SDB.Localize("Title")
  WS.Cells(1,4).Value = SDB.Localize("Length")
  WS.Cells(1,5).Value = SDB.Localize("Year")
  WS.Cells(1,6).Value = SDB.Localize("Genre")
  WS.Cells(1,7).Value = SDB.Localize("Bitrate")
  WS.Cells(1,8).Value = SDB.Localize("Media")

  WS.Rows("1:1").Font.Bold = True

  Dim ms2Day
  ms2Day = 24*60*60*1000

  ' Iterate through the list and export all songs
  Progress.MaxValue = list.count
  Dim i, itm
  for i=0 to list.count-1
    Set itm = list.Item(i)
    Dim bitrate
    bitrate = itm.bitrate
    if bitrate>0 then
      bitrate = CStr(Round( bitrate/1000))
    else
      bitrate = ""
    end if
    Dim year
    year = itm.year
    if year<=0 then
      year = ""
    else
      year = CStr( year)
    end if

    WS.Cells(i+2,1).Value = itm.ArtistName
    WS.Cells(i+2,2).Value = itm.AlbumName
    WS.Cells(i+2,3).Value = itm.title
    WS.Cells(i+2,4).NumberFormat = "mm:ss"
    If itm.SongLength>=0 Then
      WS.Cells(i+2,4).Value = itm.SongLength / ms2Day
    End If
    WS.Cells(i+2,5).Value = year
    WS.Cells(i+2,6).Value = itm.Genre
    WS.Cells(i+2,7).Value = bitrate
    WS.Cells(i+2,8).Value = itm.MediaLabel

    Progress.Value = i+1
    if Progress.Terminate then
      Exit For
    end if
  next

  ' Was it successfull?
  Dim ok
  if Progress.Terminate then
    ok = False
  else
    ok = True
    WB.SaveAs fullfile
  end if

  WB.Close false

  ' hide progress
  Set Progress = Nothing

  FinishExport( ok)
End Sub

Sub ExportXML
  ' initialize export
  Call InitExport (".xml", SDB.Localize("XML (*.xml)|*.xml|All files (*.*)|*.*"), _
      "LastExportXMLDir")
  if fullfile="" then
    Exit Sub
  end if

  ' Create the output file
  Dim fout
  Set fout = fso.CreateTextFile( fullfile, True)

  ' Use progress to notify user about the current action
  Dim Progress
  Set Progress = SDB.Progress
  Dim ProgressString
  ProgressString = SDB.Localize("Exporting...")

  Dim i
  Dim Artists, Artist
  Set Artists = list.Artists
  Dim Albums, Album
  Set Albums = list.Albums

  fout.WriteLine "<?xml version='1.0'?>"
  fout.WriteLine "<MusicDatabase>"

  Progress.MaxValue = list.count + Artists.Count + Albums.Count

  Progress.Text = ProgressString & " (artists)"
  fout.WriteLine "  <Artists>"
  for i=0 to Artists.count-1
    Set Artist = Artists.Item(i)
    fout.WriteLine "    <Artist id=""Artist_"&Artist.id&""">"
    fout.WriteLine "       <Name>" & MapXML(Artist.Name) & "</Name>"
    fout.WriteLine "    </Artist>"
    Progress.Increase
    if Progress.Terminate then
      Exit For
    end if
  next
  fout.WriteLine "  </Artists>"

  Progress.Text = ProgressString & " (albums)"
  fout.WriteLine "  <Albums>"
  for i=0 to Albums.count-1
    Set Album = Albums.Item(i)
    fout.WriteLine "    <Album id=""Album_"&Album.id&""">"
    fout.WriteLine "       <PerformingArtist id="""& Album.Artist.id & """>" & MapXML(Album.Artist.Name) & "</PerformingArtist>"
    fout.WriteLine "       <Name>" & MapXML(Album.Name) & "</Name>"
    fout.WriteLine "    </Album>"
    Progress.Increase
    if Progress.Terminate then
      Exit For
    end if
  next
  fout.WriteLine "  </Albums>"

  ' Iterate through the list and export all songs
  Progress.Text = ProgressString & " (songs)"
  fout.WriteLine "  <Songs>"
  Progress.MaxValue = list.count
  Dim Song, Media
  for i=0 to list.count-1
    Set Song = list.Item(i)
    fout.WriteLine "    <Song id=""Song_"&Song.id&""">"
    fout.WriteLine "       <Title>" & MapXML(Song.Title) & "</Title>"
    fout.WriteLine "       <PerformingArtist id=""Artist_"& Song.Artist.id & """>" & MapXML(Song.ArtistName) & "</PerformingArtist>"
    fout.WriteLine "       <ContainedInAlbum id=""Album_"& Song.Album.id & """>" & MapXML(Song.AlbumName) & "</ContainedInAlbum>"
    fout.WriteLine "       <SongLength ms="""& Song.SongLength &""">" & MapXML(Song.SongLengthString) & "</SongLength>"
    if Song.Year>0 then
      fout.WriteLine "       <Year value="""& MapXML(Song.Year) &"""/>"
    end if
    if Song.Genre<>"" then
      fout.WriteLine "       <Genre>"& MapXML(Song.Genre) &"</Genre>"
    end if
    fout.WriteLine "       <Bitrate>"& MapXML(Song.Bitrate) &"</Bitrate>"

    fout.WriteLine "       <Location>"
    Set Media = Song.Media
    If Not IsNull( Media) And Not IsEmpty( Media) And IsObject( Media) Then
      fout.WriteLine "         <Media id=""Media_"&Media.id&""" sn=""" & _
        Media.SerialNumber & """>"& MapXML(Media.MediaLabel) &"</Media>"
    End If

    fout.WriteLine "         <Path>"& MapXML(Song.Path) &"</Path>"
    fout.WriteLine "       </Location>"

    fout.WriteLine "    </Song>"
    Progress.Increase
    if Progress.Terminate then
      Exit For
    end if
  next
  fout.WriteLine "  </Songs>"

  fout.WriteLine "</MusicDatabase>"

  ' Close the output file and finish
  fout.Close

  ' Was it successfull?
  Dim ok
  if Progress.Terminate then
    ok = False
  else
    ok = True
  end if

  ' hide progress
  Set Progress = Nothing

  Call FinishExport( ok)
End Sub
Post Reply