Skip to content

Instantly share code, notes, and snippets.

@anzz1
Created March 10, 2025 12:31
Show Gist options
  • Save anzz1/cd48ac3b995252c56b216829be585131 to your computer and use it in GitHub Desktop.
Save anzz1/cd48ac3b995252c56b216829be585131 to your computer and use it in GitHub Desktop.
unixlf.cmd
<# :
@setlocal disabledelayedexpansion enableextensions
@echo off
powershell -nol -noni -nop -ex bypass -c "&{[ScriptBlock]::Create((cat '%~f0') -join [Char[]]10).Invoke(@(&{$args}%*))}"
exit /b
#>
Write-Host === CRLF -> LF ===`n
$items = dir .\ -recurse | where {$_.extension -in ".sln",".vcproj",".vcxproj",".vcxproj.filters",".md",".cs",".c",".h",".cpp",".inc",".hpp",".txt",".cc",".log",".def",".asm",".mk",".s",".json",".lua",".xml",".ini",".sql",".cfg",".nsh",".nsi",".sma",".php",".sh",".res",".bat",".conf",".js"}
if ($args[0] -ceq 'y') {
foreach($file in $items)
{
Write-Host Processed: $file.Name
$text = [IO.File]::ReadAllText($file.FullName) -replace "`r`n", "`n"
[IO.File]::WriteAllText($file.FullName, $text)
}
Write-Host `nDone.
}
else {
foreach($file in $items)
{
Write-Host File: $file.Name
}
Write-Host `nTo confirm and process these files enter `'unixlf y`'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment