Last active
February 7, 2023 16:40
-
-
Save gsusI/b4a01901e33b8b09921fdbd976a613ec to your computer and use it in GitHub Desktop.
EOL from CRLF to LF recursively: this script will convert all files in the current directory and all subdirectories to unix line endings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Set the parameters | |
$path = Get-Location | |
$numbOfThreads = 50 | |
$exclude_patterns = "^.*(\.git|\.idea|node_modules|\.next|\.(jpeg|jpg|png|gif|mp4|mkv|mp3|wav)$).*$" | |
# Find filles to convert | |
$files = Get-ChildItem -Path $path -Recurse -Include * -File -Force | Where-Object {$_.FullName -notmatch $exclude_patterns} | |
Write-Host "Found $($files.Count) files" | |
$files | ForEach-Object -Parallel { | |
if ((Get-Content $_.FullName -Raw) -match "\r") { | |
Write-Host "Converting $($_.FullName)" | |
dos2unix $_.FullName | |
} | |
} -ThrottleLimit $numbOfThreads | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment