Skip to content

Instantly share code, notes, and snippets.

@manualbashing
Last active August 27, 2019 14:45
Show Gist options
  • Select an option

  • Save manualbashing/afacdb31490ec0e02eee3891c62479cd to your computer and use it in GitHub Desktop.

Select an option

Save manualbashing/afacdb31490ec0e02eee3891c62479cd to your computer and use it in GitHub Desktop.
Convert all files in the current folder from CRLF to LF (recursively)
# Explicit version
$files = Get-ChildItem -Recurse -File
foreach ($path in $files.FullName)
{
$crlfContent = Get-Content $path
$lfContent = ($crlfContent -join "`n") + "`n"
Set-Content -Path $path -Value $lfContent -NoNewline
}
# Short version
(ls -Rec -File).FullName | % {$p = $_; ((gc $p) -join "`n") + "`n" | sc -N $p}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment