Created
September 30, 2017 04:12
-
-
Save zironycho/d4814ae7075ac6f8569aa7b657879870 to your computer and use it in GitHub Desktop.
trans-subs.py
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
import sys | |
import os | |
import codecs | |
# euc-kr to utf-8 with BOM | |
def convert(path): | |
with codecs.open(path, 'r', 'euc-kr', errors='ignore') as f: | |
out_lines = [] | |
for line in f.readlines(): | |
out_lines += [line] | |
with codecs.open(path, 'w', 'utf-8') as f: | |
# BOM | |
f.write(u'\ufeff') | |
for line in out_lines: | |
f.write(line) | |
for r, d, fs in os.walk(sys.argv[1]): | |
for f in fs: | |
if f.endswith('.smi'): | |
try: | |
path = os.path.join(r, f) | |
print(path) | |
convert(path) | |
except Exception as e: | |
print(e) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment