VBSCript reporting Error 13 , Error (Hex): D

November 19, 2015 at 23:18:11
Specs: Windows Server 2008 R2
Merging multiple CSV files available in Network Path using Vbscript.
The script is erring out with following error
runscript.msg.STDERR
Error: 13
Error (Hex): D
Source: Microsoft VBScript runtime error
Description: Type mismatch

The VBScript used is

Set objFSO = CreateObject("Scripting.FileSystemObject")
objStartFolder = "T:\CSVFolder"
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8

Set objFolder = objFSO.GetFolder(objStartFolder)
Wscript.Echo objFolder.Path

Set colFiles = objFolder.Files

is_first_file = True
outCSVFile = "T:\Merged\Performance.csv"
Set objOutFile = objFSO.OpenTextFile(outCSVFile, ForWriting, True)

read_header = False
header_line = ""

For Each curr_file in colFiles
If UCase(objFSO.GetExtensionName(curr_file.Name)) = "CSV" Then
Wscript.Echo curr_file.Name
' open file for reading
Set objFile = objFSO.OpenTextFile(curr_file.Name, ForReading)
If is_first_file = True Then
Do Until objFile.AtEndOfStream
strTemp = objFile.ReadLine
If Not strTemp = "" Then
' write line to combined csv file
objOutFile.WriteLine strTemp
End If
Loop
' close current opened csv file
objFile.Close
is_first_file = False
Else
row_count = 0
Do Until objFile.AtEndOfStream
strTemp = objFile.ReadLine
row_count = row_count + 1
If (Not strTemp = "") AND (row_count > 1) Then
' write line to combined csv file
objOutFile.WriteLine strTemp
End If
Loop
' close current opened csv file
objFile.Close
End If
End If
Next
Wscript.Echo "merged all csv files in folder"

message edited by JeevanMallya


See More: VBSCript reporting Error 13 , Error (Hex): D

Report •


#1
November 20, 2015 at 01:24:03
At what line does the error occur?

Note that

Set objFile = objFSO.OpenTextFile(curr_file.Name, ForReading)

assumes that you run the script from the "T:\CSVFolder" folder.


Report •

#2
November 22, 2015 at 20:34:07
The following error is reported.

The scripts error output stream:
Error: 13
Error (Hex): D
Source: Microsoft VBScript runtime error
Description : Type mismatch

I am not executing the script from "T:\CSVFolder" .
This folder contains all CSV files to be merged and once merged i am saving it in a different folder "T:\Merged\Performance.csv"

The script is executed from C:\Scripts\WindowsScript

message edited by JeevanMallya


Report •

Related Solutions


Ask Question