I am trying to change the encoding of multiple files to UTF8, read the files with findstr
and once read change the encoding back to unicode (UTF16-LE).
This is my powershell command I am trying to run within my batch file:
powershell -command "$apb=(gc config\_temp\path.txt)+'\APBGame\Localization\GER\'; Get-ChildItem $apb\ -Filter *.GER -recurse | Foreach-Object {Get-Content $_.FullName | Set-Content -Encoding utf8 ($_.FullName)}"
Running that command gives me this error:
Set-Content : The process cannot access the file 'E:\SteamLibrary\steamapps\common\APB Reloaded\APBGame\Localization\GER\FILE.GER'
because it is being used by another process.
At line:1 char:150
+ ... {Get-Content $_.FullName | Set-Content -Encoding utf8 ($_.FullName)}
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Set-Content], IOException
+ FullyQualifiedErrorId : System.IO.IOException,Microsoft.PowerShell.Commands.SetContentCommand
I get this error for every file.
I have already used Process Explorer to identify possible processes that could've used the .GER files by searching for the handle ".GER". No matches were found.
I run multiple powershell commands within my batch file but this one is the only one using the variable $apb
incase that's important.