Python - Way to recursively find and replace string in text files
<p>I want to recursively search through a directory with subdirectories of text files and replace every occurrence of {$replace} within the files with the contents of a multi line string. How can this be achieved with python?</p>

<p><strong>[EDIT]</strong></p>

<p>So far all I have is the recursive code using os.walk to get a list of files that are required to be changed.</p>

<pre><code>import os
import sys
fileList = []
rootdir = "C:\\test"
for root, subFolders, files in os.walk(rootdir):
  if subFolders != ".svn":
    for file in files:
      fileParts = file.split('.')
      if len(fileParts) &gt; 1:
        if fileParts[1] == "php":
          fileList.append(os.path.join(root,file))


print fileList
</code></pre>
