Код:
Код: Выделить всё
test1.bin
3132330D0A3435370D0A3835как через BAT файл заменить "3435" на "3436" чтобы получился файл test2.bin ?
Код:
Код: Выделить всё
test2.bin
3132330D0A3436370D0A3835
Архив с тестовыми файлами:
Код: Выделить всё
test1.bin
3132330D0A3435370D0A3835Код: Выделить всё
test2.bin
3132330D0A3436370D0A3835
Код: Выделить всё
$as_bytes = Get-Content test1.bin -Raw -Encoding byte
$as_text = $as_bytes.forEach('ToString', 'X2') -join ' '
$patternregex = ('31 32 33 0D 0A 34 35 37 0D 0A 38 35')
$patch = '31 32 33 0D 0A 34 36 37 0D 0A 38 35'
$checkPattern=Select-String -Pattern $patternregex -InputObject $as_text
If ($checkPattern -ne $null) {
$as_text_replaced = $as_text -replace $patternregex, $patch
}
Elseif (Select-String -Pattern $patch -InputObject $as_text) {
Write-Output ' Already patch, exiting'
Exit
}
else {
Write-Output "Byte not found"
}
[byte[]] $as_bytes_replaced = -split $as_text_replaced -replace '^', '0x'
Set-Content test2.bin -Encoding Byte -Value $as_bytes_replaced
Код: Выделить всё
@echo off
copy test1.bin test2.bin
call JREPL.BAT \x34\x35 \x34\x36 /XSEQ /M /F "test2.bin" /O -
call JREPL.BAT \x0A\x38 \x0A\x38\x38 /XSEQ /M /F "test2.bin" /O -Код: Выделить всё
@echo off
copy test1.bin test2.bin
set "F1=\x34\x35"
set "R1=\x34\x36"
set "F2=\x0A\x38"
set "R2=\x0A\x38\x38"
call JREPL.BAT "%F1% %F2%" "%R1% %R2%" /T " " /XSEQ /M /F "test2.bin" /O -Код: Выделить всё
@echo off
copy test1.bin test2.bin
call JREPL _find.txt _replace.txt /T FILE /XSEQ /M /F "test2.bin" /O -
