with open("getrepo.bat") as f: d = [a.strip().split(" ") for a in f.readlines()] q = [] for a in d: q.append(" ".join(a[:-1] + [a[-1].replace("/", "\\")])) with open("getrepo.bat", "w") as f: f.write("\n".join(q))