Playlist Exporter to .PLA files

Download and get help for different MediaMonkey for Windows 4 Addons.

Moderators: Peke, Gurus

IJuan
Posts: 2
Joined: Sun Jun 18, 2006 8:53 pm

Playlist Exporter to .PLA files

Post by IJuan »

I modified the ExportM3Us.vbs script to export all playlists in MediaMonkey to .pla files to be used with my Sandisk Sansa E200 series MP3 player. It may work for other devices that use PLA/PLP files. It assumes that you use "\Music\Album Artist\Album\Filename" when you sync your tracks to the player.

This did take very long to modify. If there are more options that would make this more useful let me know and I can try to make the changes.

Code: Select all

' !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
' This file is a modifed version of the ExportM3U.vbs 
' script. This was created to make playlist for the Sandisk
' Sansa E200 series mp3 player. It may work with other mp3 
' players that use PLA/PLP playlist files. Here is a sample 
' of what can be added to the Scripts.ini file. 
'
'[ExportPLAs]
'FileName=ExportPLAs.vbs
'ProcName=ExportPLAs
'Order=45
'DisplayName=Export all Playlists to PLA...
'Description=Exports all Playlists to .pla
'Language=VBScript
'ScriptType=0
'
' !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Option Explicit     ' report undefined variables, ...

' SDB variable is connected to MediaMonkey application object

' Recursively process all playlists
Sub ReadPlaylists( playlists, plst, prefix)
  Dim items
  Set items = plst.ChildPlaylists

  If prefix<>"" Then
    prefix = prefix & " - "
  End If

  Dim i, newplst, title
  For i=0 To items.Count-1
    Set newplst = items.Item(i)
    title = prefix & newplst.Title
    If Not playlists.exists(title) Then
      playlists.Add title, newplst
    End If
    ReadPlaylists playlists, newplst, title
  Next
End Sub

Function AddSpacing(strOriginal)
  Dim strWithSpacing, i
  
  For i = 1 to len(StrOriginal)
    strWithSpacing = strWithSpacing & Mid(strOriginal, i, 1) & Chr(00)
  Next
  
  AddSpacing = strWithSpacing & Chr(13) & Chr(00) & Chr(10) & Chr(00)
End Function

Function GetFileName(FullPath)
  Do While InStr(FullPath, "\") <> 0
    FullPath = Mid(FullPath, Instr(FullPath, "\") + 1)
  Loop
  GetFileName = FullPath
End Function

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

  ' Let user select the output path
  Dim path
  path = iniF.StringValue( "Scripts", "LastExportPLAsDir")

  path = SDB.SelectFolder( path, SDB.Localize( "Select where to export all PLA/PLP files."))

  If path="" Then
    Exit Sub
  End If

  If Right( path, 1)<>"\" Then
    path = path & "\"
  End If

  ' Write selected directory to the ini file
  iniF.StringValue( "Scripts", "LastExportPLAsDir") = path
  Set iniF = Nothing

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

  Dim playlists
  Set playlists = CreateObject("Scripting.Dictionary")

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

  ' Prepare a list of all playlists
  ReadPlaylists playlists, SDB.PlaylistByTitle( ""), ""

  ' Go through the list and export each playlist
  Dim i, iTrck, plst, fout, plsts, titles, title, tracks, trck, ln', tlen, art, tit
  plsts = playlists.Items
  titles = playlists.Keys
  Progress.MaxValue = playlists.count
  For i=0 To playlists.Count-1
    Set plst = plsts(i)
    Set tracks = plst.Tracks
    title = Titles(i)
    Progress.Text = ExpText & " (" & title & ")"
    Set fout = fso.CreateTextFile( path & fso.CorrectFilename(title) & ".pla", True)
    fout.Write AddSpacing("PLP PLAYLIST")
    fout.Write AddSpacing("VERSION 1.20")
    fout.Write AddSpacing("")
    If tracks.Count>0 Then
      For iTrck=0 To tracks.Count-1
        Set trck = tracks.Item(iTrck)
        ln = "HARP, MUSIC\" & trck.ArtistName & "\" & trck.AlbumName & "\" & GetFileName(trck.Path)
        fout.Write AddSpacing(ln)
      Next
      fout.Close
    End If
    Progress.Value = i+1
  Next
End Sub
<-IJuan->
stretch
Posts: 8
Joined: Wed Sep 21, 2005 4:56 pm

sansa forum

Post by stretch »

Hi,

You might want to post this handy script to this good sansa forum as there a few MM users that might want to use it.

http://www.anythingbutipod.com/forum/fo ... ay.php?f=9
IJuan
Posts: 2
Joined: Sun Jun 18, 2006 8:53 pm

Post by IJuan »

I already did post this script there also. It has fallen way down in the forum because of lack of interest.
vphreeze
Posts: 26
Joined: Thu Aug 17, 2006 11:45 pm

Post by vphreeze »

awesome little script. i have one question though, how could i edit to use the folder structure:

\Music\Genre\Artist\Album\Filename

instead of the built in one?
Guest

Re: sansa forum

Post by Guest »

stretch wrote:Hi,

You might want to post this handy script to this good sansa forum as there a few MM users that might want to use it.

http://www.anythingbutipod.com/forum/fo ... ay.php?f=9
Rascal_
Posts: 35
Joined: Thu Dec 14, 2006 3:09 pm
Contact:

Post by Rascal_ »

Please help. I haven't had this script work for me.

I backed up C:\Program Files\MediaMonkey\Scripts\ExportM3Us.vbs and added the script from the first post with the file name ExportM3Us.vbs in the same directory.

I sync my Sansa e260. Old music files get deleted, and new mp3s get copied fine to the player, as best as I can tell. However, in /PLAYLISTS/, I get the play lists as .m3u's. I was expected .pla (isn't that the proper format for Sansa?). Am I doing something wrong?
trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK
Contact:

Post by trixmoto »

Save the file as "ExportPLAs.vbs", open "Scripts.ini" in a text editor and add...

Code: Select all

[ExportPLAs]
FileName=ExportPLAs.vbs
ProcName=ExportPLAs
Order=45
DisplayName=Export all Playlists to PLA...
Description=Exports all Playlists to .pla
Language=VBScript
ScriptType=0
Then restart MM and try again.

Edited By Peke: I just removed Comments ' from Code above.
Download my scripts at my own MediaMonkey fansite.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
Peke
Posts: 18526
Joined: Tue Jun 10, 2003 7:21 pm
Location: Earth
Contact:

Post by Peke »

Updated code in post above, as it didn't work.
Best regards,
Peke
MediaMonkey Team lead QA/Tech Support guru
Admin of Free MediaMonkey addon Site HappyMonkeying
Image
Image
Image
How to attach PICTURE/SCREENSHOTS to forum posts
Rascal_
Posts: 35
Joined: Thu Dec 14, 2006 3:09 pm
Contact:

Post by Rascal_ »

Thanks trixmoto. Now I understand what that means.

I did as you said and my first try was unsuccessful. I'm cleared all the playlist and music directories and restarting MM again.

If there is something else to try out, please let me know. If this second attempt is successful, I'll post here. Otherwise, I'm still stumped.

Is there an option somewhere to tell MM to use PLA instead of M3U?
Rascal_
Posts: 35
Joined: Thu Dec 14, 2006 3:09 pm
Contact:

Post by Rascal_ »

Na, the second attempt still created a .m3u playlist. I'm obviously not understanding something.
Peke
Posts: 18526
Joined: Tue Jun 10, 2003 7:21 pm
Location: Earth
Contact:

Post by Peke »

If you done all correctly you should see File->Create Reports->Export all Playlists to PLA....
Best regards,
Peke
MediaMonkey Team lead QA/Tech Support guru
Admin of Free MediaMonkey addon Site HappyMonkeying
Image
Image
Image
How to attach PICTURE/SCREENSHOTS to forum posts
Rascal_
Posts: 35
Joined: Thu Dec 14, 2006 3:09 pm
Contact:

Post by Rascal_ »

Peke, no I don't see that.

I see Statistics, Track List (HTML), Track List (XML), Track List (CSV), Track List (Excel). This is an out of the box installation.

Looking at my Scripts.ini, that corresponds to the first five entries. However, I do not get the following entries which are in the Scripts.ini which include AutoTrackN, SwapArtistTitle, Case, etc. The order numbers increment by 5, if that matters.
Rascal_
Posts: 35
Joined: Thu Dec 14, 2006 3:09 pm
Contact:

Post by Rascal_ »

Okay, I did see Tools> Scripts> Export All Playlists to PLA.

Am I not not doing a step?

I'm expecting to click on sync, MM downloads the proper tracks to my Sansa, and then downloads the playlist in PLA format. Is this the correct idea?

Do I have to do an extra step here to convert the m3u to pla? I get the feeling that if I click on this script in the Scripts menu, it will convert all of the MM playlists I have to PLA, which I don't want to do.

Thank you. I appreciate the help.

[edited to add:]
Oh, how does MM know to export pla to my Sansa? I can't find any option in my audio device configuration.

I did run the script and pointed to my sansa, but as I thought, it exported all the MM playlists (as far as I can tell) to my sana. I don't know how to limit it to just the playlists on my device.

I appreciate the help in muddling through this. I'm a new beginner.
Peke
Posts: 18526
Joined: Tue Jun 10, 2003 7:21 pm
Location: Earth
Contact:

Post by Peke »

Ask IJuan to modify His script to add additional things to its script.

Examples how to use Selection of playlist with Rightclick could be found in ScrobblerDJ Script where I use it to set Default playlist. Unfortunately this needs to be done by experienced Scripter.
Best regards,
Peke
MediaMonkey Team lead QA/Tech Support guru
Admin of Free MediaMonkey addon Site HappyMonkeying
Image
Image
Image
How to attach PICTURE/SCREENSHOTS to forum posts
Rascal_
Posts: 35
Joined: Thu Dec 14, 2006 3:09 pm
Contact:

Post by Rascal_ »

Apparently, those who posted in this thread have not been active in these forums for a while. I'll try to post a pm.

Meanwhile, I'm sure there are other Sansa e200 users who use playlists. Is it that hard to use MM to put them on the player?

I appreciate the help so far!
Post Reply