import os
import glob
import string
old_name_ext = '*.ini'
new_name_ext = '*.txt'
old_ext = old_name_ext.lstrip('*')
new_ext = new_name_ext.lstrip('*')
tmp = glob.glob(old_name_ext)
log = open('renamelog.log','a')
for f in tmp:
new_name = string.replace(f, old_ext, new_ext)
print 'rename',f,' to ',new_name
log.write('rename'+f+' to '+new_name)
os.rename(f,new_name)
log.close()