24 lines
979 B
C#
24 lines
979 B
C#
using System;
|
|
using System.IO;
|
|
using System.Text.RegularExpressions;
|
|
|
|
Console.WriteLine("GCode for Drawbot Conversion Tool\n* * * * * * * * * * * * * * * * *");
|
|
string currentPath = Directory.GetCurrentDirectory();
|
|
string[] curFiles = Directory.GetFiles(currentPath, "*.ngc?");
|
|
foreach (string filename in curFiles) {
|
|
Console.WriteLine("Modifying: " + filename);
|
|
using (var reader = new StreamReader(filename)) {
|
|
string fileText = reader.ReadToEnd();
|
|
fileText = Regex.Replace(fileText, "([ ][Z]([^ |\n])*)", "");
|
|
fileText = Regex.Replace(fileText, "(\n[G][0][0]\n)", "\n");
|
|
//Console.Write(fileText + "\n");
|
|
string newFile = Path.GetDirectoryName(filename) + "\\" + Path.GetFileNameWithoutExtension(filename) + ".gcode";
|
|
Console.WriteLine("Saving to: " + newFile);
|
|
File.WriteAllText(newFile, fileText);
|
|
}
|
|
}
|
|
|
|
foreach (string v in curFiles) {
|
|
Console.WriteLine("Deleting File: " + v);
|
|
File.Delete(v);
|
|
} |