Skip to content

Instantly share code, notes, and snippets.

@Yepoleb
Created June 8, 2014 16:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Yepoleb/b11aef2efc5c7e97b513 to your computer and use it in GitHub Desktop.
Save Yepoleb/b11aef2efc5c7e97b513 to your computer and use it in GitHub Desktop.
import os.path
import re
oldfiles = "playerfiles/"
newfiles = "newfiles"
logre = re.compile("logout: (\d+)")
for filename in os.listdir(oldfiles):
oldpath = os.path.join(oldfiles, filename)
newpath = os.path.join(newfiles, filename)
f = open(oldpath, "r")
text = f.read()
f.close()
logouts = logre.search(text).group(1)
logoutms = int(logouts) * 1000
logoutstr = "logout: {}".format(logoutms)
newtext = logre.sub(logoutstr, text)
f = open(newpath, "w")
f.write(newtext)
f.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment