I wrote a simple script to copy .wav files from a temp location to another folder. The temp location has a folder structure:
\\TempWavs\YYYY\MM\DD\HH\*.wav
I'm copying the .wav files to another location, and then deleting the .wav file from the temp location. However, I'm receiving this error:
Line 23
Char 3
Permission Denied
800A0046
MicroSoft VBScript runtime error
Here's the code:
Set objFSO = CreateObject("Scripting.FileSystemObject")
objStartFolder = "D:\TempWavs"
Set objFolder = objFSO.GetFolder(objStartFolder)
Set colFiles = objFolder.Files
ShowSubfolders objFSO.GetFolder(objStartFolder)
Sub ShowSubFolders(Folder)
For Each Subfolder in Folder.SubFolders
Set objFolder = objFSO.GetFolder(Subfolder.Path)
Set colFiles = objFolder.Files
set filesys = CreateObject("Scripting.FileSystemObject")
dim WavFolder
For Each objFile in colFiles
EncFolder = Mid(objFile.Name, 19, 1)
If right(objFile.Name, 3) = "wav" Then
filesys.CopyFile objfile, "D:\Data\0"&WavFolder&"", True
filesys.DeleteFile objFile, True
End If
Next
ShowSubFolders Subfolder
Next
End Sub
I'm executing the script with a batch file as a scheduled task. It will sometime execute successfully, but other times it generates the Permission Denied error and hangs.
\\TempWavs\YYYY\MM\DD\HH\*.wav
I'm copying the .wav files to another location, and then deleting the .wav file from the temp location. However, I'm receiving this error:
Line 23
Char 3
Permission Denied
800A0046
MicroSoft VBScript runtime error
Here's the code:
Set objFSO = CreateObject("Scripting.FileSystemObject")
objStartFolder = "D:\TempWavs"
Set objFolder = objFSO.GetFolder(objStartFolder)
Set colFiles = objFolder.Files
ShowSubfolders objFSO.GetFolder(objStartFolder)
Sub ShowSubFolders(Folder)
For Each Subfolder in Folder.SubFolders
Set objFolder = objFSO.GetFolder(Subfolder.Path)
Set colFiles = objFolder.Files
set filesys = CreateObject("Scripting.FileSystemObject")
dim WavFolder
For Each objFile in colFiles
EncFolder = Mid(objFile.Name, 19, 1)
If right(objFile.Name, 3) = "wav" Then
filesys.CopyFile objfile, "D:\Data\0"&WavFolder&"", True
filesys.DeleteFile objFile, True
End If
Next
ShowSubFolders Subfolder
Next
End Sub
I'm executing the script with a batch file as a scheduled task. It will sometime execute successfully, but other times it generates the Permission Denied error and hangs.