Hi Folks,
Need a hand here. I just got a new Car Stereo that takes SD cards, but the
file format is WAY different than what Windows Media player synchs to the
cards. I'm trying to read a .m3u playlist file and take each song and copy
it to the SD card in a 8 character folder name of the play list.
I keep getting "Permission Denied" errors. The music lives on a server in
my house and I'm attempting to copy mp3 over the network to my SD card local
to my client by double clicking on the .vbs file. Here is the script so
far: (PS, it's not optimized, or cleaned up)
------
Set objFSO = CreateObject("Scripting.FileSystemObject")
Dim PlayListName
Dim SFNPlayListName
Dim PlayListFile
Dim SDCardDrive
' Changable Playlist Options
PlayListName = "Driving Trax"
PlayListFile = "\\server\Music\Playlists\Driving.m3u"
SFNPlayListName = "DRVNG"
SDCardDrive = "G:"
'Check to see if the target exists, if it does, delete it
DestDir = SDCardDrive & "\" & SFNPlayListName
If objFSO.FolderExists(DestDir) Then
Set DelFolder = objFSO.GetFolder (DestDir)
DelFolder.Delete
End If
'Re create the folder and prep for copy
Set MakeFolder = objFSO.CreateFolder(DestDir)
Const ForReading = 1
Set plFile = objFSO.OpenTextFile(PlayListFile, ForReading)
Do Until plFile.AtEndOfStream
txtLine = plFile.ReadLine
If Len(txtLine) <> 0 Then
If Left(txtLine, 1) <> "#" Then
'Wscript.Echo ("Copy " & txtLine & " to " & DestDir)
If ObjFSO.FileExists(txtLine) Then
Set ws = WScript.CreateObject ("WScript.shell")
ObjFSO.CopyFile txtLine, DestDir '
Permission Denied here!
End If
End If
End If
Loop
plFile.close
Wscript.Quit
-----
I labelled the line I get permission denied on, I can't for the life of me
figure out why, because if I take the commented "echo" line and copy and
paste it into a CMD window, it works fine. Moreover, if I replace that
permission denied line with:
Call ws.run("cmd.exe /c copy " & Chr(34) & txtLine &
Chr(34) & " " & DestDir & "\")
It works fine (although it opens up about 80 CMD windows and freezes
explorer until the copy is complete).
Any idea why I'm getting permission denied here? Does the WSH block access
to copy files (I was able to delete above?!?) or something?
Thanks for the help!
Sean