Question

I have a bat file where I encode some CSV files. The problem is that there are one character at the begining of the file once the encoding have been done (BOM byte I guess). This character bothers me cause after encoding, I use this file to generate a database. Here is the line for encoding (inside bat file):

powershell -Command "&{ param($Path); (Get-Content $Path) | Out-File $Path -Encoding UTF8 }" CSVs\\pass.csv

Is there any way to encode the file without BOM (if this is the problem)??

Thanks!

Was it helpful?

Solution

I found the solution. Just change the line with this:

powershell -Command "&{ param($Path); $Utf8NoBomEncoding = New-Object System.Text.UTF8Encoding($False); $MyFile = Get-Content $Path; [System.IO.File]::WriteAllLines($Path, $MyFile, $Utf8NoBomEncoding) }" CSVs\\pass.csv
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top