I got a script that I want to use to change a repeated string throughout a project folder structure. Once changed then I can check this into SVN. However when I run my script it goes into the .svn folders which I want it to ingore. How can I achieve this? Code below, thanks.
import os
import sys
replacement = "newString"
toReplace = "oldString"
rootdir = "pathToProject"
for root, subFolders, files in os.walk(rootdir):
print subFolders
if not ".svn" in subFolders:
for file in files:
fileParts = file.split('.')
if len(fileParts) > 1:
if not fileParts[len(fileParts)-1] in ["dll", "suo"]:
fpath = os.path.join(root, file)
with open(fpath) as f:
s = f.read()
s = s.replace(toReplace, replacement)
with open(fpath, "w") as f:
f.write(s)
print "DONE"