jeffharbert icon

Edit playlist and copy its songs to an Android device

jeffharbert | PRO | 04/07/13 01:17:32 AM UTC | 0 ⭐ | 351 👁️ | Never ⏰ | []
text |

2.21 KB

|

None

|

0 👍

/

0 👎

Const ForReading = 1
Const ForWriting = 2
 ' Set your constants.
' The path to the M3U playlist saved from Winamp running on Windows.
Const strPlaylist = "C:\Users\Jeff\Documents\Faves.m3u"
' The path to the folder that will hold the songs of the playlist on the Android device.
Const strPlaylistLocation = "E:\Music\Faves\"
' Same as above, but just the folder name itself.
Const strFileLocation = "Faves\"
' The path to the playlist that will end up on the Android device.
Const strNewPlaylist = "E:\Music\Faves.m3u"
 strEditedPlaylist = ""
strEditedPlaylistTemp = ""
 Set objFSO = CreateObject("Scripting.FileSystemObject")
 If Not objFSO.FolderExists(strPlaylistLocation) Then
  objFSO.CreateFolder strPlaylistLocation
End If
 Set objPlaylist = objFSO.OpenTextFile(strPlaylist, ForReading)
 Do Until objPlaylist.AtEndOfStream
strLine = objPlaylist.ReadLine
' We only need to grab lines from the M3U file that contain file paths.
' I use "\\" below because Winamp on my PC monitors a UNC path, so that's what ends up in the M3U file.
' You can change this to "c:" or other drive letter as needed.
	If Left(strLine,2) = "\\" Then
		strSourceFilePath = strLine
' Isolate the file name from the full path
		arrFields = Split(strLine, "\")
		i = UBound(arrFields)
		strDestFileName = arrFields(i)
' Use the file name to construct a path to the Android device,
' using the defined strPlaylistLocation variable.
		strDestFilePath = strPlaylistLocation + strDestFileName
' If the file already exists at the destination, skip copying it.
			If Not objFSO.FileExists(strDestFilePath) Then
				wScript.Echo strDestFileName
				objFSO.CopyFile strSourceFilePath, strDestFilePath
			End If
' Build the new M3U file in RAM.
		strEditedPlaylistTemp = strEditedPlaylist + strFileLocation + strDestFileName + VbCrLf
		strEditedPlayList = strEditedPlayListTemp
	End If
Loop
objPlaylist.Close
 ' Create a blank M3U file if it doesn't already exist
If Not objFSO.FileExists(strNewPlaylist) Then
	objFSO.CreateTextFile strNewPlaylist
End If
 ' Write the new M3U file to the Android device
Set objNewPlaylist = objFSO.OpenTextFile(strNewPlaylist, ForWriting)
objNewPlaylist.Write strEditedPlaylist
objNewPlaylist.close

Comments