Advertisement
Guest User

Shining Nikki Powershell Code

a guest
Jan 22nd, 2021
443
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $PATH = "enter ur path here"
  2. $BYTES_TO_TRIM = 8
  3.  
  4. $files = dir $PATH | where { !$_.PsIsContainer }
  5.  
  6. foreach ($file in $files) {
  7.     Write-Output "File being truncated: $($file.FullName)"
  8.     Write-Output "  Original Size: $($file.Length) bytes"
  9.     Write-Output "  Truncating $BYTES_TO_TRIM bytes..."
  10.     $byteEncodedContent = [System.IO.File]::ReadAllBytes($file.FullName)
  11.     $truncatedByteEncodedContent = $byteEncodedContent[$BYTES_TO_TRIM..($byteEncodedContent.Length - 1)]
  12.     Set-Content -value $truncatedByteEncodedContent -encoding byte -path "$($file.FullName)"
  13.  
  14.     Write-Output "  Size after truncation: $((Get-Item $file.FullName).Length) bytes"
  15.     Write-Output "Truncation done!`n"
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement