Skip to content

Instantly share code, notes, and snippets.

@davidmcclure
Created March 21, 2012 14:27
Show Gist options
  • Save davidmcclure/2147386 to your computer and use it in GitHub Desktop.
Save davidmcclure/2147386 to your computer and use it in GitHub Desktop.
import os, sys
for subdir, dirs, files in os.walk(sys.argv[1]):
print subdir
for file in files:
print file
f = open(subdir+'/'+file, 'r')
lines = f.readlines()
f.close()
f = open(subdir+'/'+file, 'w')
for line in lines:
newline = line.replace(sys.argv[2], sys.argv[3])
f.write(newline)
f.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment