'-------------------------------------------------------------------- 'Sansa™ UNICODE *.pla Playlist Converter 'PlaylistConverter.vbs 'Copyright© 2008 Timothy P. Markoski 'tmarkoski@machinist-toolbox.com 'All Rights Reserved ' 'DISCLAIMER OF WARRANTY: 'THIS SOFTWARE IS SUPPLIED "AS IS" AND WITHOUT WARRANTIES 'AS TO PERFORMANCE OF MERCHANTABILITY OR ANY OTHER 'WARRANTIES WHETHER EXPRESSED OR IMPLIED. ' 'NO WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE IS OFFERED. 'THE USER MUST ASSUME THE ENTIRE RISK OF USING THE PROGRAM. ' 'Sansa™ is the Trademark of the SanDisk Corporation ' '-------------------------------------------------------------------- 'Directions for use with Sansa MSC device '-------------------------------------------------------------------- 'Copy this text in an editor and save as a *.vbs file on your PC. 'Double click on this file to execute the conversion. ' 'Users may browse and convert *.pla files on Sansa™ units directly 'as long as Sansa™ unit in connected to PC and set to MSC in USB Mode. '-------------------------------------------------------------------- Call Main Sub Main() On Error Resume Next 'Object Declaration Dim objShell Dim objFolder Dim objFSO Dim objFSOFolder Dim objFSOFiles Dim objFSOFile Dim objFile Dim objNewFile Dim objTextStream 'Variable Declaration Dim strPath Dim strLine Dim strData Dim strNewFile Dim strM3UFile 'Create the Shell and folder Objects Set objShell = CreateObject("Shell.Application") Set objFolder = objShell.BrowseForFolder ( 0,"Browse for Folder with UNICODE *.pla Playlists",17) strPath = objFolder.ParentFolder.ParseName(objFolder.Title).Path 'Create the File System Object we need to do the work Set objFSO = CreateObject("Scripting.FileSystemObject") 'Get the folder Set objFSOFolder = objFSO.GetFolder(strPath) 'Get the files in the folder Set objFSOFiles = objFSOFolder.Files 'Loop through all the files in the folder For Each objFSOFile In objFSOFiles 'Check for stnadard *.pla playlist or Go List.plp file If ((Right(objFSOFile.Name,4) = ".pla") Or (Right(objFSOFile.Name,4) = ".plp")) Then 'New *.m3u file name from *.pla file If (Right(objFSOFile.Name,4) = ".pla") then strNewFile = Replace(objFSOFile.Name,".pla",".m3u") End If 'New *.m3u file name from *.plp file If (Right(objFSOFile.Name,4) = ".plp") Then strNewFile = Replace(objFSOFile.Name,".plp",".m3u") End if 'Open the UNICODE playlist file Set objFile = objFSO.OpenTextFile(strPath & "\" & objFSOFile.Name, 1, False, -1) 'Initialize the variables for storing the read line and for holding the new playlist data strLine = vbnullstring strData = vbNullString 'Establish the header for the *.m3u file strData = "#EXTM3U" 'Loop through the play list and get the music file path data Do While Not objFile.AtEndOfStream strLine = objFile.ReadLine If InStr(1,strLine,"HARP, MUSIC\",1) > 0 Then strLine = Replace(strLine,"HARP, MUSIC\",vbNullString) strData = strData & vbCrLf & strLine end if Loop 'Make sure we have a carriage return and line feed at the end of the file strData = strData & vbCrLf 'Close the file objFile.Close '***************************************************** '*.m3u FIle creation section '***************************************************** 'Establish the full qualified path and file name strM3UFile = strPath & "\" & strNewFile 'Create the new empty *.m3u file objFSO.CreateTextFile strM3UFile 'Get the file Set objNewFile = objFSO.GetFile(strM3UFile) 'Open the text stream for writing Set objTextStream = objNewFile.OpenAsTextStream(2) 'Write the playlist data to the file objTextStream.Write strData 'Close the file objTextStream.Close End if Next If Not Err Then MsgBox "UNICODE *.pla playlists in :" & vbCrLf & vbCrLf & strPath & _ vbCrLf & vbCrLf & " converted to DOS ASCII *.m3u playlists." & vbCrLf & vbCrLf & _ "Copy *.m3u files to MUSIC folder on Sanas Device", vbInformation,"Sansa™ UNICODE *.pla Playlist Converter" End If 'Explicit cleanup Set objShell = Nothing Set objFolder = Nothing Set objFSO = Nothing Set objFSOFolder = Nothing Set objFSOFiles = Nothing Set objFile = Nothing Set objNewFile = Nothing Set objTextStream = Nothing End Sub