cproudlock dc80aceafb Initial commit - eDNC Special Character Fix
Real-time file watcher to strip invalid characters (0xFF, etc.)
from DNC program files for CNC machine compatibility.

Features:
- Monitors folder for .pun files (configurable)
- Automatically cleans files on create/modify
- Configurable character removal
- Retry logic for locked files
- Session statistics

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-12 08:30:37 -05:00

eDNC Special Character Fix

Real-time file watcher that automatically removes invalid special characters from DNC (Direct Numerical Control) program files.

Problem

Some legacy DNC systems and communication protocols add padding or termination bytes that modern CNC controllers cannot process correctly. Common problematic characters include:

Byte Hex Name Description
255 0xFF Fill Padding/fill character
0 0x00 NULL Null character
26 0x1A SUB Ctrl+Z / EOF marker
127 0x7F DEL Delete character

Solution

This utility monitors a folder for DNC files and automatically strips specified characters as soon as files are created or modified.

Installation

  1. Copy the project folder to your DNC workstation
  2. Edit eDNC-SpecialCharFix.ps1 to set your watch folder (default: C:\Dnc_Files\Q)
  3. Run Run-eDNCFix.bat or create a shortcut

Run at Startup (Optional)

To run automatically at Windows startup:

  1. Press Win + R, type shell:startup, press Enter
  2. Create a shortcut to Run-eDNCFix.bat in the Startup folder

Usage

Basic Usage

Double-click Run-eDNCFix.bat or run from PowerShell:

.\eDNC-SpecialCharFix.ps1

Custom Watch Folder

.\eDNC-SpecialCharFix.ps1 -WatchFolder "D:\DNC\Programs"

Different File Types

.\eDNC-SpecialCharFix.ps1 -FileFilter "*.nc"

Remove Additional Characters

# Remove 0xFF, NULL, and SUB characters
.\eDNC-SpecialCharFix.ps1 -CharactersToRemove @(255, 0, 26)

All Options

.\eDNC-SpecialCharFix.ps1 `
    -WatchFolder "C:\Dnc_Files\Q" `
    -FileFilter "*.pun" `
    -IncludeSubfolders $true `
    -CharactersToRemove @(255)

Parameters

Parameter Type Default Description
WatchFolder String C:\Dnc_Files\Q Folder to monitor
FileFilter String *.pun File pattern to watch
IncludeSubfolders Boolean $true Watch subdirectories
CharactersToRemove Int[] @(255) Byte values to strip

Output

The script displays real-time activity:

========================================
 eDNC Special Character Fix v1.0.0
========================================

Configuration:
  Watch Folder:    C:\Dnc_Files\Q
  File Filter:     *.pun
  Subfolders:      True
  Removing bytes:  255 (0xFF)

Watching for files... Press Ctrl+C to stop

2025-12-12 08:30:15 | Created | PART001.pun
  [CLEANED] Removed 3 byte(s)
2025-12-12 08:30:22 | Changed | PART002.pun
  [OK] No special characters found

Requirements

  • Windows PowerShell 5.1 or later
  • Read/Write access to the watch folder

Troubleshooting

"Watch folder does not exist"

Create the folder or specify a different path with -WatchFolder.

"File locked" errors

The script retries up to 3 times if a file is locked. If errors persist, the file may be in use by another application.

Script doesn't detect files

  • Verify the file extension matches -FileFilter
  • Check that -IncludeSubfolders is set correctly
  • Ensure the script has permissions to the folder

Version History

Version Date Changes
1.0.0 2025-12-12 Initial release

Author

GE Aerospace - Rutland

Description
eDNC Special Character Fix - Real-time DNC file cleaner
Readme 98 KiB
Languages
PowerShell 94.3%
Batchfile 5.7%