Created
September 16, 2010 09:54
-
-
Save kenegozi/582193 to your computer and use it in GitHub Desktop.
fixing text files to DOS style line endings (CRLF)
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
c:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe fix_crlf.cs | |
fix_crlf.exe |
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
using System; | |
using System.Collections.Generic; | |
using System.IO; | |
using System.Linq; | |
using System.Text; | |
namespace FixCrLF | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var extensions = new[] {".aspx", ".cs", ".boo", ".css", ".js", ".txt"}; | |
var root = Environment.CurrentDirectory; | |
var files = from f in Directory.EnumerateFiles(root, "*.*", SearchOption.AllDirectories) | |
let ext = Path.GetExtension(f) | |
where ext != null && extensions.Contains(ext) | |
select f; | |
foreach (var file in files) | |
{ | |
Console.Write(file + " ... "); | |
var originalContent = File.ReadAllLines(file); | |
File.WriteAllLines(file, originalContent); | |
Console.WriteLine("done"); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment