CRLF を LF に一括変換する
引数に glob を指定
shell で展開されないようにクオートで囲む必要あり
python3 crlf2lf.py "**/*.js"
import sys | |
import glob | |
for arg in sys.argv[1:]: | |
for path in glob.glob(arg, recursive=True): | |
with open(path, "rb") as f: | |
text1 = f.read().decode() | |
text2 = text1.replace("\r\n", "\n") | |
if text1 == text2: | |
print("SKIP", path) | |
else: | |
with open(path, "wb") as f: | |
f.write(text2.encode()) | |
print("CONV", path) |