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

Re: Help with Permission Denied by Brian

Brian
Sun Aug 13 01:57:16 CDT 2006

Sean Daniel wrote:
> 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?

Does Destdir have a trailing slash? It appears not, based on the ws.run
call above. From the docs:

If source contains wildcard characters or destination ends with a path
separator (\), it is assumed that destination is an existing folder in
which to copy matching files. Otherwise, destination is assumed to be
the name of a file to create. In either case, three things can happen
when an individual file is copied.

If destination does not exist, source gets copied. This is the usual case.
If destination is an existing file, an error occurs if overwrite is
false. Otherwise, an attempt is made to copy source over the existing file.
If destination is a directory, an error occurs.

Re: Help with Permission Denied by Sean

Sean
Mon Aug 14 19:57:29 CDT 2006

Wow! that was it, the destination dir needed the "\".

Thanks Brian, that helps a lot!
Sean


"Brian Wolven" <brian.wolven@domain.invalid> wrote in message
news:efAA1WqvGHA.324@TK2MSFTNGP06.phx.gbl...
> Sean Daniel wrote:
>> 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?
>
> Does Destdir have a trailing slash? It appears not, based on the ws.run
> call above. From the docs:
>
> If source contains wildcard characters or destination ends with a path
> separator (\), it is assumed that destination is an existing folder in
> which to copy matching files. Otherwise, destination is assumed to be the
> name of a file to create. In either case, three things can happen when an
> individual file is copied.
>
> If destination does not exist, source gets copied. This is the usual case.
> If destination is an existing file, an error occurs if overwrite is false.
> Otherwise, an attempt is made to copy source over the existing file.
> If destination is a directory, an error occurs.