File: class/Extras/Other/_old-Tools/packaging/Scripts/toboth.py
# ex: python %X%\tools\todos.py *.*
# converts files in current directory only
import string, sys, glob
def convert(From, To):
if len(sys.argv) > 1: # glob anyhow: '*' not applied on dos
patts = sys.argv[1:] # though not really needed on linux
else:
patts = ['*.py', '*.txt', '*.c', '*.h', 'make*']
files = map(glob.glob, patts)
print files
for list in files:
for fname in list:
print fname
t = open(fname, 'r').read()
s = string.join(string.split(t, From), To) # or replace()
o = open(fname, 'w')
o.write(s)