Last active
February 14, 2019 06:55
-
-
Save baobao/110036747e572dde2a03384b90d4ac7c to your computer and use it in GitHub Desktop.
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
# -*- coding: UTF-8 -*- | |
import os.path | |
import sys | |
import xml.etree.ElementTree as ET | |
# 書き出し相対ディレクトリパス | |
# 適宜設定する | |
BaseRelativePath='export/' | |
args = sys.argv | |
# tpsファイルチェック | |
tpsPath = args[1] | |
if not tpsPath or tpsPath.find('.tps') < 0: | |
print('ERROR : 「.tps」ではないので、処理を中断します') | |
sys.exit() | |
# xmlファイルの読み込み | |
tree = ET.parse(tpsPath) | |
root = tree.getroot() | |
# 拡張子を抜いたファイル名を取得する | |
path,ext = os.path.splitext(tpsPath) | |
temp = path.split("/") | |
noExFileName = temp[len(temp)-1] | |
# 書き出しパスの設定ノードの取得 | |
exportNode=root.find('struct/map/struct/filename') | |
# 新しい書き出しパスで上書き | |
exportNode.text = BaseRelativePath + noExFileName + '.tpsheet'; | |
# .tpsを上書き保存します | |
tree.write(tpsPath, 'utf-8', True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment