I need a programmatic way to repeatedly convert a downloaded CSV into an XLS, essentially keeping the same name of the file and just replacing the XLS each time. I work on a Mac 10.12, and am well-versed in the command line, but haven't found an easy way to do this without having to download a third-party library. I found an answer that gave me a VBscript that I can use on PowerShell, but I need some help with it.
I've downloaded PowerShell and I'm able to use it in Terminal. I have this script from another StackOverflow question:
Dim file, WB
With CreateObject("Excel.Application")
On Error Resume Next
For Each file In WScript.Arguments
Set WB = .Workbooks.Open(file)
WB.SaveAs Replace(WB.FullName, ".csv", ".xlsx"), 51
WB.Close False
Next
.Quit
End With
WScript.Echo "Done!"
What would be the command to execute this script (in PowerShell) with an argument?
I've tried a variation of execution commands but always get CommandNotFoundException
, probably because I'm doing it super wrong. My ideal outcome here is that Desktop/data.csv
can become Desktop/data.xls
repeatedly, whether it's with this script or something infinitely easier for a Mac user.
Thank you!
*edited for specificity/simplification