Last active
March 2, 2016 14:01
-
-
Save sarathlal-old/b80cd269d4a78c7f4ab4 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, fnmatch | |
def findReplace(directory, filePattern): | |
for path, dirs, files in os.walk(os.path.abspath(directory)): | |
for filename in fnmatch.filter(files, filePattern): | |
filepath = os.path.join(path, filename) | |
with open(filepath) as f: | |
s = f.read().splitlines(True) | |
with open(filepath, "w") as f: | |
f.write("<?php") | |
f.writelines(s[1:]) | |
# findReplace("directory", "*file extension") | |
findReplace("/var/www/project_20", "*.php") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment