import string
import sys
import os

# this program fixes a list of files to not have the damn MAC
# formating characters

files = sys.argv[1:]
for f in files:
	#make backup
	os.system('cp '+ f + ' ' + f +'.bak')

	#read in file
	fd = open( f, 'r')
	st = fd.read()
	fd.close()

	#fix MAC format chars
	st = string.replace( st, chr(146), "'")
	st = string.replace( st, chr(147), "<EM>")
	st = string.replace( st, chr(148), "</EM>")
	st = string.replace( st, chr(150), '--')
	st = string.replace( st, chr(160), '&nbsp;')

	
	#truncate, write, and close the file
	fd = open(f, 'w')
	fd.write( st )
	fd.close()

