Created
August 10, 2023 19:28
-
-
Save Jonathan727/9abf7ba290b32f74ae21e8fa55c631eb to your computer and use it in GitHub Desktop.
Powershell command to convert all xlsx files in a directory to csv files.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$excelApp = New-Object -ComObject Excel.Application;` | |
$excelApp.DisplayAlerts = $false;` | |
Get-ChildItem -File -Filter '*.xlsx' | ForEach-Object { ` | |
$workbook = $excelApp.Workbooks.Open($_.FullName);` | |
$csvFilePath = $_.FullName -replace "\.xlsx$", ".xlsx.csv";` | |
<# If Microsoft.Office.Interop.Excel.XlFileFormat, try running from Visual Studio Developer Powershell #>` | |
$workbook.SaveAs($csvFilePath, [Microsoft.Office.Interop.Excel.XlFileFormat]::xlCSV);` | |
$workbook.Close();` | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment