Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $PATH = "enter ur path here"
- $BYTES_TO_TRIM = 8
- $files = dir $PATH | where { !$_.PsIsContainer }
- foreach ($file in $files) {
- Write-Output "File being truncated: $($file.FullName)"
- Write-Output " Original Size: $($file.Length) bytes"
- Write-Output " Truncating $BYTES_TO_TRIM bytes..."
- $byteEncodedContent = [System.IO.File]::ReadAllBytes($file.FullName)
- $truncatedByteEncodedContent = $byteEncodedContent[$BYTES_TO_TRIM..($byteEncodedContent.Length - 1)]
- Set-Content -value $truncatedByteEncodedContent -encoding byte -path "$($file.FullName)"
- Write-Output " Size after truncation: $((Get-Item $file.FullName).Length) bytes"
- Write-Output "Truncation done!`n"
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement