slyfox1186

trim_blank_end_line+remove_quotes.ps1

May 5th, 2021 (edited)
169
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # THIS SCRIPT IS MEANT TO BE CALLED BY A BATCH FILE
  2. # THE BATCH FILE WILL PASS A FILE PATH AS AN ARGUMENT TO THIS SCRIPT
  3. # DOWNLOAD LINK: https://pastebin.com/hkpKpr5D
  4.  
  5. # SAVE FIRST ARGUMENT (THE PASSED FOLDER/FILE PATH) IN A VARIABLE
  6. $InFile = $args[0]
  7. # CREATE OUTPUT FILE TO AVOID PROCESS IN USE ERRORS
  8. $OutFile = "$pwd\Split_Path_After.txt"
  9.  
  10. # REMOVE ANY SURROUNDING QUOTES
  11. (Get-Content $InFile) | ForEach-Object {$_ -Replace '"',''} | Out-File "$OutFile"
  12.  
  13. # REMOVE THE BLANK LAST LINE OF FILE
  14. $RemoveEOFBlank = [System.IO.File]::ReadAllText($OutFile)
  15. $RemoveEOFBlank = $RemoveEOFBlank.Trim()
  16. [System.IO.File]::WriteAllText($OutFile, $RemoveEOFBlank)
  17.  
  18. # OPEN THE OUTPUT FILE
  19. Start-Process -FilePath 'C:\Windows\notepad.exe' "$OutFile" -WindowStyle Maximized
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×