EDIT: - Working files with Rigoletto's edits attached!
So I made a bind to stop a demo, move it to another folder and start a new demo.
Unfortunately it doesn't give the file a very good name at all (just the time and date) so Rigoletto has suggested I post what I have here for help to make it better.
Here's what I have.
A python file "DemoScript.py"
import os
import sys
from time import strftime
# *Defining functions here.
# Move a file, and handle any errors if the filename is already taken.
def safeMove(num):
# Realisitically you won't have 5 demos named the same I hope...
# Especially since it's down to the second, so this is really just in case you have already this
# Time in use somehow..
# So if this gets to 5, I give up, we've a problem moving/renaming the file, so just gtfo.
newName = strftime("%Y-%m-%d at time %H-%M-%S") + ".demo"
if num > 5:
return
try:
if num == 0:
os.rename(demosPath+newestFile,newPath+newName);
else:
os.rename(demosPath+newestFile,newPath+newName+str(num));
except WindowsError as winErr:
safeMove(num+1)
# *Declaring Variables...
# Where your demos are recorded to.
demosPath = "C:\\Program Files (x86)\\Savage XR\\game\\demos\\"
# Where you want to move the demo to.
newPath = "C:\\Program Files (x86)\\Savage XR\\game\\GoodDemos\\"
# *The program starts here really.
# First things first, lets make sure the directory we want to write to exists.
# If it doesn't, lets make it.
if not os.path.exists(newPath):
os.makedirs(newPath)
# And to be safe, make sure we have the directory where the demo is.
# If not, get out.
if not os.path.exists(demosPath):
sys.exit()
# Find most recent file
allFiles = os.listdir(demosPath)
newestFile = ""
for filename in allFiles:
if ((os.path.getctime(demosPath+filename) > os.path.getctime(demosPath+newestFile))):
newestFile = filename
# The parameter is to try change the filename if we have trouble moving it.
# 0 means don't try change.
safeMove(0)
and a .cfg file "demoexec.cfg"
python "execfile('C:\\Program Files (x86)\\Savage XR\\game\\DemoScript.py')";
msg #name# "Demo saved and moved :)"
So at present I'm just binding a key as follows
bind f9 "demostop;exec demoexec.cfg;demorecord"