Skip to content

Instantly share code, notes, and snippets.

@Hashbrown777
Last active September 28, 2023 02:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Hashbrown777/a34e68cc5189438828dfe734e3efc43d to your computer and use it in GitHub Desktop.
Save Hashbrown777/a34e68cc5189438828dfe734e3efc43d to your computer and use it in GitHub Desktop.
Resizes files anchoring to EOF
'3705688449 ,setup_cyberpunk_2077_build_4902785change_6408866_with_ep1_rl_(64bit)_(67718)-25.bin
2124976 ,setup_cyberpunk_2077_build_4902785change_6408866_with_ep1_rl_(64bit)_(67718).exe
30669496 ,setup_cyberpunk_2077_redmod_build_4902785change_6408866_with_ep1_rl_(64bit)_(67718).exe' -split '\n' `
| %{
$expected,$name = $_ -split ','
$expected = [UInt32]$expected
$diff = (gci $name).Length - $expected
if (!$diff) {
return
}
$bs = 1
while (!($diff -band 1)) {
$bs *= 2
$diff /= 2
}
dd `
"if=$name" `
"of=${name}_" `
"bs=$bs" `
"$(('seek','skip')[!($diff -lt 0)])=$([Math]::Abs($diff))"
gci $name | Rename-Item -NewName "_$name"
gci "${name}_" | Rename-Item -NewName $name
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment