All pastes #164331 Raw Edit

Mine

public text v1 · immutable
·published 2006-09-08 14:59 UTC
rendered paste body
import os, sys

PATH=r"C:\Programme\L2j Server\jscript"
TYPES={'q':'quests','b':'blacksmith','v':'village_master','t':'teleports','c':'custom'}

j=os.path.join
log=open("log.log", "w")
sys.stdout=log
changed=0

for abbr, full in TYPES.iteritems():
	print "\n", full, "\n*************"
	path=j(PATH, full)
	files=os.listdir(path)
	for dir in files:	
		fulldir=j(path, dir)
		if os.path.isdir(fulldir) and dir[0].isdigit():
			init=j(fulldir, '__init__.py')
			if os.path.isfile(init):
				f=open(init, "r")
				script=f.read()
				f.close()
				count=script.count(dir)
				if count:
					script=script.replace(dir, abbr+dir)
					changed=1
				else:
					print "WARNING: %s found %s times in %s" % (dir, count, init)
				f=open(init, "w")
				f.write(script)
				f.close()
				if changed:
					os.rename(fulldir, j(path, abbr+dir))
					changed=0
	print "completed", full