Skip to content

Instantly share code, notes, and snippets.

@Arcensoth
Created March 21, 2018 18:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Arcensoth/5f638b4594417c44d99697771b18fa4b to your computer and use it in GitHub Desktop.
Save Arcensoth/5f638b4594417c44d99697771b18fa4b to your computer and use it in GitHub Desktop.
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