Created
April 6, 2019 20:25
-
-
Save geryxyz/030d5b466a2a9f7409b9776cc98a313a to your computer and use it in GitHub Desktop.
Setting speed for CNC *.tap file in a banch, it will change all F instruction with the new specified speed and create a new file. It scan the current working directory and will process all *.tap expect the results of previous execution.
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
import sys | |
import re | |
import glob | |
import os.path | |
import pdb | |
speed = int(sys.argv[1]) | |
files = glob.glob("*.tap") | |
for original in files: | |
exts = os.path.splitext(original) | |
if re.search(r'F\d+$', exts[0]): | |
print("skipping file: %s" % original) | |
else: | |
new = '%s.F%d.tap' % (exts[0], speed) | |
print(original + " --> " + new) | |
with open(original, 'r') as in_file, open(new, 'w') as out_file: | |
for line in in_file: | |
if re.search(r'F\d+', line): | |
new_line = re.sub(r'F\d+', 'F%d' % speed, line) | |
out_file.write(new_line) | |
else: | |
out_file.write(line) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://photos.app.goo.gl/YmkD6A9pWWwmpMZv6