-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdemo-reader-list.py
More file actions
52 lines (42 loc) · 1.57 KB
/
demo-reader-list.py
File metadata and controls
52 lines (42 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import os
# P-REC currently not supported
### Fill in before use
events = "" # Change this if your events file is not in your demos folder (default is to not change)
demos = r"C:\Program Files (x86)\Steam\steamapps\common\Team Fortress 2\tf\demos" # Change if demos folder is at another path
### THIS WILL USE THE TEST FILES, REMOVE # FOR TESTING
#events = ""
#demos = "testdemos"
if events == "":
event_path = demos + "\_events.txt"
else:
event_path = events
events = open(event_path, "r")
done_demos = {}
count = 0
total_count = 0
for marks in events:
try:
if '"' in marks:
# Hitta demo, ta ut namn och tick
print("Found tick on demo",marks)
total_count += 1
demo_name = marks[38:57]
tick = marks[62:-2]
print(demo_name,"nästa",tick)
# Spara namn och tick
if demo_name in done_demos.keys():
done_demos[demo_name] = done_demos[demo_name] + "_" + tick
else:
done_demos[demo_name] = tick
except FileNotFoundError:
print("Demo on",demo_name,"not found. Maybe already checked or moved?")
# Byt namn på filer
for new_name in done_demos.keys():
try:
print("hej")
print(demos + "\\" + new_name + ".dem", demos +"\\"+done_demos[new_name] + ".dem")
print("hej")
os.rename(demos + "\\" + new_name + ".dem", demos +"\\"+done_demos[new_name] + ".dem")
except FileNotFoundError:
print("RENAME: Demo on",new_name,"not found. Maybe already checked or moved?")
events.close()