Didn't you say that you're using Python 2.7 now? The default file
encoding will be ASCII, but your file isn't ASCII, it contains Greek
letters. Add the encoding line:
   # -*- coding: utf-8 -*-
and check that the file is saved as UTF-8.
sctually its for currdir, dirs, filesin os.walk('test'): thats whay
ti couldnt run!!
After changifn this and made some other modification my convertion
script finally run!
Here it is for someone that might want a similar functionality.
======================================================================
#!/usr/bin/python
# -*- coding: utf-8 -*-
import re, os, sys
count = 520
for currdir, dirs, files in os.walk('d:\\akis'):
for f in files:
if f.lower().endswith("php"):
# get abs path to filename
src_f = os.path.join(currdir, f)
# open php src file
f = open(src_f, 'r')
src_data = f.read()
f.close()
# Grab the id number contained within the php code and insert it
above all other data
found = re.search( r'PageID = (\d+)', src_data )
if found:
id = found.group(1)
else:
id = count =+ 1
src_data = ( '<!-- %s -->\n\n' % id ) + src_data
# replace php tags and contents within
src_data = re.sub( r'(?s)<\?(.*?)\?>', '', src_data )
# add template variables
src_data = src_data.replace( '</body>', '<br><br><center><h4><font
color=green> ΑÏιθμός Επισκεπτών: %(counter)d </body>' )
# open same php file for storing modified data
f = open(src_f, 'w')
f.write(src_data)
f.close()
# rename edited .php file to .html extension
dst_f = src_f.replace('.php', '.html')
os.rename( src_f, dst_f )
print ( "renaming: %s => %s\n" % (src_f, dst_f) )