Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Convert-Eol() {
- Param(
- [Parameter(Mandatory=$true)]
- [ValidateNotNullOrEmpty()]
- [string[]] $Files,
- [Parameter(Mandatory=$false)]
- [ValidateNotNullOrEmpty()]
- [Text.Encoding] $Encoding = [Text.Encoding]::Default,
- [Parameter(Mandatory=$true)]
- [ValidateNotNullOrEmpty()]
- [ValidateSet("Cr", "Crlf", "Lf")]
- [string] $Eol
- )
- $eols = @{
- "Cr" = "`r";
- "Crlf" = "`r`n";
- "Lf" = "`n";
- }
- foreach ($file in $Files) {
- $file = Resolve-Path $file
- $text = [IO.File]::ReadAllText($file)
- if ($Eol -ne "Lf") {
- $text = $text -replace $eols["Lf"], $eols[$Eol]
- }
- [IO.File]::WriteAllText($file, $text)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement