パワーシェルでバイナリーファイルを読んで文字列を置換する

文字列の長さも同じで小さいファイルに対応します

コード

pwsh -command "$bytes = [System.IO.File]::ReadAllBytes('C:\app\aviutl\180.aup'); for ($i = 0; $i -lt $bytes.Length - 4; $i++) { if ([System.Text.Encoding]::ASCII.GetString($bytes[$i..($i+3)]) -eq '001.') { [System.Text.Encoding]::ASCII.GetBytes('265.').CopyTo($bytes, $i) } }; [System.IO.File]::WriteAllBytes('Y:\aviutl\180.aup', $bytes)"

bat,PowerShell 

Posted by eightban