Skip to content

Instantly share code, notes, and snippets.

@barnaba
Created September 18, 2013 09:28
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 barnaba/6606746 to your computer and use it in GitHub Desktop.
Save barnaba/6606746 to your computer and use it in GitHub Desktop.
import re
import os
from collections import OrderedDict
#configuration
KillStreakFile = "/home/barnex/test/KillStreaks.txt"
DemoDirectory = "/home/barnex/test"
KillStreakRegex = "\"(.*)\""
DemoFileExtension = ".dem"
demos_with_killstreaks = []
f = open(KillStreakFile, 'r')
for line in f:
m = re.search(KillStreakRegex, line)
if m:
demos_with_killstreaks.append(m.group(1).lower() + DemoFileExtension.lower())
f.close()
print "keeping %d demos" % len(OrderedDict.fromkeys(demos_with_killstreaks).keys())
files_to_delete = [file for file in os.listdir(DemoDirectory) if (file.lower().endswith(DemoFileExtension) and not file.lower() in demos_with_killstreaks)]
print "DEBUG"
print "-> demos kept:"
for demo in demos_with_killstreaks:
print " -> %s" % demo
print "-> demos deleted:"
for demo in files_to_delete:
print " -> %s" % demo
#for file in files_to_delete:
#print "deleting: %s" % file
#os.remove(DemoDirectory + "/" + file)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment