Replace and inserting strings within .txt files with the use of regex
__peter__ at web.de
Mon Aug 9 09:38:34 CEST 2010
> Now the code looks as follows:
> for currdir, files, dirs in os.walk('test'):
> for f in files:
> if f.endswith('php'):
> # get abs path to filename
> src_f = join(currdir, f)
> I just tried to test it. I created a folder names 'test' in me 'd:\'
> Then i have put to .php files inside form the original to test if it
> would work ok for those too files before acting in the whole copy and
> after in the original project.
> so i opened a 'cli' form my Win7 and tried
> Itsjust printed an empty line and nothign else. Why didn't even try to
> open the folder and fiels within?
> Syntactically it doesnt ghive me an error!
> Somehting with os.walk() methos perhaps?
If there is a folder D:\test and it does contain some PHP files (double-
check!) the extension could be upper-case. Try
if f.lower().endswith("php"): ...
php_files = fnmatch.filter(files, "*.php")
for f in php_files: ...
More information about the Python-list