I faced the same problem.
Attached python script converts mine.
#!/usr/bin/env python3
import sys
import os
def convert_drill_file_final_adjustment(input_filename):
output_data = []
output_data.append("M48\n")
output_data.append("INCH\n")
output_data.append("T01C0.040\n")
output_data.append("%\n")
output_data.append("T01\n") # Ensure T01 is added before coordinates
# Read input data from the specified file
with open(input_filename, 'r') as file:
input_data = file.readlines()
for line in input_data:
line = line.strip()
if line.startswith("X"):
x_part, y_part = line.split("Y")
# Convert to integer to remove any incorrect leading zeros, then format to required length
x_val = f"{int(x_part[1:]):05d}" + "0" # Convert to integer, 5 digits, add trailing zero
y_val = f"{int(y_part):05d}" + "0" # Convert to integer, 5 digits, add trailing zero
output_data.append(f"X+{x_val}Y+{y_val}\n")
elif line == "M30":
output_data.append("T00\n")
output_data.append("M30\n")
break
# Replace ".xln" with ".drill" in the output filename, or just add ".drill" if no ".xln" is present
output_filename = input_filename.replace(".xln", "") + ".drill"
with open(output_filename, 'w') as file: # 'w' mode overwrites the file
file.write(''.join(output_data))
# Print output to the console
print(''.join(output_data))
# Check if the script is called with an input filename argument
if len(sys.argv) != 2:
print("Usage: python3 convert_drill.py <input_file>")
sys.exit(1)
# Usage: take the input filename from command line argument
os.chdir(os.getcwd())
input_file = sys.argv[1]
convert_drill_file_final_adjustment(input_file)