# Powershell - normalizing line endings for all files in a directory

If you’re working with a git repository, a much better way to solve this is by changing the core.autocrlf setting.  In this case I didn’t have that option, and needed a quick way to update thousands of files so the EOL chars would match in a binary diff tool.  Here’s my slightly modified version of this SO answer:

$items = get-childitem -Path “C:\path\to\dir" -Recurse -Fileforeach($original_file in $items){$text = [IO.File]::ReadAllText($original_file.FullName) -replace “rn”, “n" [IO.File]::WriteAllText($original_file.FullName, \$text)}`