Created
March 21, 2018 18:44
-
-
Save Arcensoth/5f638b4594417c44d99697771b18fa4b to your computer and use it in GitHub Desktop.
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 os | |
import sys | |
dirpath = sys.argv[1] | |
oldtext = sys.argv[2] | |
newtext = sys.argv[3] | |
for root, subdirs, files in os.walk(dirpath): | |
for filename in files: | |
filepath = os.path.join(root, filename) | |
print(filepath) | |
with open(filepath, 'r') as fp: | |
data = fp.read() | |
data = data.replace(oldtext, newtext) | |
with open(filepath, 'w') as fp: | |
fp.write(data) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment