I am making script to convert excel files into csv files. Excel files are in downloads folder and start with "START". Only the first file is converted and then php is still running, but nothing happens. Running it from browser I can see the circle is running eternally, like loading the website. This is the code:
$path = "C:\Users\\tom\Downloads\\";
foreach(glob($path."*.xls") as $excel_file) {
$substr = substr($excel_file, 24, 5);
if($substr = "START") {
$csv_file = str_replace(".xls", ".csv", $excel_file);
exec("$path"."csv.vbs $excel_file $csv_file");
}
}
the script I am using is csv.vbs script and the code is:
if WScript.Arguments.Count < 2 Then
WScript.Echo "Error! Please specify the source path and the destination. Usage: XlsToCsv SourcePath.xls Destination.csv"
Wscript.Quit
End If
Dim oExcel
Set oExcel = CreateObject("Excel.Application")
Dim oBook
Set oBook = oExcel.Workbooks.Open(Wscript.Arguments.Item(0))
oBook.SaveAs WScript.Arguments.Item(1), 6
oBook.Close False
oExcel.Quit
WScript.Echo "Done"
using shell_exec is the same. What is wrong here?