-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathstripper.ps1
40 lines (34 loc) · 1.13 KB
/
stripper.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
## Powershell function to quickly strip content out of file
function Strip-All
{
<#
.SYNOPSIS
PowerShell cmdlet to remove new lines and comments from a script and output a new version of the script
.DESCRIPTION
script to quickly strip newlines and comments out of a file
Currently dosn't handle header descriptions like this part!
.PARAMETER in
this is the file you are stripping
.PARAMETER out
this is the file you are writing out that has been stripped
.EXAMPLE
PS C:\> Import-Module Stripper.ps1
PS C:\> Strip-All -i inputfile.ps1 -o outputfile.ps1
.LINK
https://github.com/ahhh/
http://lockboxx.blogspot.com/
http://stackoverflow.com/questions/9223460/remove-empty-lines-from-text-file-with-powershell.NOTES
EZ-Mode tool
#>
[CmdletBinding()] Param(
[Parameter(Mandatory = $true, ValueFromPipeline=$true)]
[Alias("i", "infile")]
[String]
$in,
[Parameter(Mandatory = $true)]
[Alias("o", "outfile")]
[String]
$out
)
[IO.File]::ReadAllText($in) -replace '\#(.+)\r\n', "`r`n" | %{$_ -replace '\#\r\n',"`r`n" } | %{$_ -replace '\s+\r\n+',"`r`n" } | Out-File $out
}