-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfsort.py
25 lines (23 loc) · 1.02 KB
/
fsort.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import os
path = os.getcwd()
for f in os.listdir(path):
if f.endswith(".txt"):
with open(os.path.join(path, f)) as data:
treetype = "none"
c = 0
out = ""
for line in data.readlines():
if "Treetype" in line:
p = os.path.join(path, "o", treetype.replace("/","\\").rsplit("\\",1)[-1] + ".txt")
os.makedirs(p.rsplit("\\",1)[0], exist_ok=True)
with open(p,"a+") as outfile:
outfile.write(out)
out = ""
treetype = line.split(" ")[-1].split("\\")[-1].replace(".srt","").replace("\n","")
elif "PositionX (Float) : " in line:
c = 6
if c > 0:
out += line.replace(" ","")
c -= 1
with open(os.path.join(path, "o", treetype.replace("/","\\").rsplit("\\",1)[-1] + ".txt"),"a+") as outfile:
outfile.write(out)