0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Kicad で Plot した Gerber File を elecrow 向けにリネームする python (適当)

Last updated at Posted at 2019-12-06

偉い人が Kicad のプラグインとして使える python スクリプト書いてるみたいだけど、
すでに出力されてるやつをリネームすることも何故か結構あるので、主に自分用に置いときます。

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)
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?