Use https://tlwiki.org/?title=Tools#RScript with an insanely high line length like 5000 so that line breaks aren't added to the script for no reason.
Use also, to clean up control formatting (modify as needed):
1 #!python
2 import sys
3 import re
4
5 for name in sys.argv[1:]:
6 if name[-4:] == ".txt":
7 with open(name, "r", encoding="cp932") as f:
8 for line in f:
9 line = line.rstrip()
10 line = re.sub(r"\^g\d\d\d", "", line)
11 line = re.sub(r"\^[nm]", "", line)
12 line = re.sub(r"\^s\d", "", line)
13 line = re.sub(r"\^d\d", "", line)
14 line = re.sub(r"^grpo_[a-z0-9]*", "", line)
15 line = re.sub(r"^grpe", "", line)
16 line = re.sub(r"^grpo", "", line)
17 line = re.sub(r"^99", "", line)
18 line = re.sub(r"\|([^\[]*)\[([^\]]*)\]", r"〈\1〉《\2》", line)
19
20 forbidden = r"""~`@#$%^&*()_+-=[]\{}|;':,./<>?"""
21
22 for c in forbidden:
23 if c in line:
24 print(line)
25 exit()
26 if line == "":
27 continue
28
29 print(line)