Last active
February 17, 2018 10:26
-
-
Save osya/752f682de132bf4dd24105486e579aaa to your computer and use it in GitHub Desktop.
Search & Replace in files #Python
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 glob | |
replace = 'https://github.com/osya' | |
replacement = '[email protected]:osya' | |
for filename in glob.iglob('E:/Work/**/.git/config', recursive=True): | |
with open(filename) as f: | |
s = f.read() | |
if replace in s: | |
print(filename) | |
s = s.replace(replace, replacement) | |
with open(filename, "w") as f: | |
f.write(s) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment