Rename Gerber File Plotted in Kicad for elecrow python (appropriate)

It looks like a great person is writing a python script that can be used as a Kicad plugin, For some reason, it's quite possible to rename the one that has already been output, so I mainly put it for myself.

elecrow.py


import glob
import re
import os
import sys

args = sys.argv
if len(args) < 2:
    print("Usage: python rename.py foldername_of_gerberfiles")
else:
    path = args[1]
    for x in glob.glob( path + "/*"):
        if re.search(r"-NPTH\.", x) is None:
            y = re.sub(r"([^-]+)\-\w+\.(\w+)",r"\1.\2",x)
            z = re.sub(r"drl$", "txt",y)
            os.rename(x,z)
            print(z)
        else:
            y = re.sub(r"drl$",r"txt",x)
            os.rename(x,y)
            print(y)

Recommended Posts

Rename Gerber File Plotted in Kicad for elecrow python (appropriate)
File operations in Python
File operations in Python
Download the file in Python
Search for strings in Python
Techniques for sorting in Python
About "for _ in range ():" in python
Convert Excel file to text in Python for diff purposes
File / folder path manipulation in Python
Check for external commands in python
Save the binary file in Python
Linebot creation & file sharing in Python
Notes for Python file input / output
ORC, Parquet file operations in Python
Run unittests in Python (for beginners)
Read a Python # .txt file for a super beginner in Python with a working .py
Exclusive control with lock file in Python
Notes on nfc.ContactlessFrontend () for nfcpy in python
Inject is recommended for DDD in Python
Tips for dealing with binaries in Python
Convert psd file to png in Python
Summary of various for statements in Python
Type annotations for Python2 in stub files!
Write O_SYNC file in C and Python
Read the file line by line in Python
Process multiple lists with for in Python
Read the file line by line in Python
Exclusive file access between processes in Python
MongoDB for the first time in Python
Get a token for conoha in python
Sample for handling eml files in Python
AtCoder cheat sheet in python (for myself)
[GPS] Create a kml file in Python
I searched for prime numbers in python
Tips for making small tools in python
Use pathlib in Maya (Python 2.7) for upcoming Python 3.7
[Python] Read the specified line in the file
Overwrite download file for python selenium Chrome