-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathremove_gcode_comments.js
More file actions
33 lines (28 loc) · 933 Bytes
/
Copy pathremove_gcode_comments.js
File metadata and controls
33 lines (28 loc) · 933 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
const fs = require('fs');
const path = require('path');
const dirs = [
'D:/hax2026hoo/3FIL/customModel/data-prep/g-code-non-gun',
'D:/hax2026hoo/3FIL/customModel/data-prep/g-code-spliced'
];
function processDirectory(dirPath) {
const files = fs.readdirSync(dirPath).filter(f => f.endsWith('.gcode'));
console.log(`Processing ${files.length} files in ${dirPath}`);
let processed = 0;
for (const file of files) {
const filePath = path.join(dirPath, file);
const content = fs.readFileSync(filePath, 'utf8');
const lines = content.split('\n');
const filtered = lines.filter(line => !line.trim().startsWith(';'));
fs.writeFileSync(filePath, filtered.join('\n'));
processed++;
}
console.log(`Processed ${processed} files`);
}
for (const dir of dirs) {
if (fs.existsSync(dir)) {
processDirectory(dir);
} else {
console.log(`Directory not found: ${dir}`);
}
}
console.log('Done!');