Convert Excel Files to CSV – Windows Script

Instructions

  1. Copy both files into the directory containing the files you want converted
  2. Run excel-to-csv.bat

Note: This script requires Excel to be installed.

excel-to-csv.bat
FOR /f delims= %%i IN (‘DIR *.xls* /b’) DO to-csv.vbs %%i %%i.csv
to-csv.vbs
if WScript.Arguments.Count < 2 Then
WScript.Echo “Please specify the source and the destination files. Usage: ExcelToCsv <xls/xlsx source file> <csv destination file>”
Wscript.Quit
End If
csv_format = 6
Set objFSO = CreateObject(“Scripting.FileSystemObject”)
src_file = objFSO.GetAbsolutePathName(Wscript.Arguments.Item(0))
dest_file = objFSO.GetAbsolutePathName(WScript.Arguments.Item(1))
Dim oExcel
Set oExcel = CreateObject(“Excel.Application”)
Dim oBook
Set oBook = oExcel.Workbooks.Open(src_file)
oBook.SaveAs dest_file, csv_format
oBook.Close False
oExcel.Quit

 1,447 total views,  6 views today

Comments

So empty here ... leave a comment!

Leave a Reply

Your email address will not be published. Required fields are marked *

Sidebar