Sign in to follow this  

Tired of refreshing your KSP install?

Recommended Posts

I’m in the camp where I think “best practice” is to leave my Steam™ installation alone, and copy the entire KSP folder to a different spot and use that to play KSP with. That also has the advantage that you can keep your existing 1.1.3 install while frolicking around with the 1.2 pre-release.

Of course there is the boring act of copying over the files from Steam when a new pre-release-release has taken place. A simple file copy will do, but there’s always the theoretical risk of leaving files from a previous release that are no longer needed. More thorough is to remove all existing files, but keep your mods and saves, and then copy the new release over.

To get a clean update, every single time, I’ve written a simply Python script that does all that for me. I’m sure there is room for improvement—let me know!

The advantage of using a script like this is the ability to extend it. This weekend I'll add a function to change some of the settings (notably using IJKL to steer rovers, and running KSP in window mode) for instance. That will be easy at this point.

Anyway, I thought sharing wouldn’t be harmful. Enjoy!

# ---------------------------------------------------------------------------
# update KSP installation by copying over from steam
# ---------------------------------------------------------------------------

import os, shutil
from zipfile import * 

# source is the location of your steam (squad?) copy
SOURCE = r'C:\Program Files (x86)\Steam\steamapps\common\Kerbal Space Program'
# dest is the actual install you're playing with
DEST = r'C:\Users\Kerbart\Documents\Kerbal Space Program 1.2'
# zipfile is where the data is temporarily saved. your system temp folder 
# would be good. or a ramdrive, if you have one.
ZIPFILE = r'R:\'
# the exception list of directories NOT to back up
EXCEPT = ['saves\\scenarios','saves\\training','gamedata\\squad']

def main():
    exec('Backup', makeZip)
    exec('Clear', clearDest)
    exec('Copy', copyAll)
    exec('Restore', extractZip)
def exec(title, function):
def clearDest():
def copyAll():
    shutil.copytree(SOURCE, DEST)

def extractZip():
    myZip = ZipFile(ZIPFILE, mode='r')

def makeZip():
    myZip = ZipFile(ZIPFILE, mode='w')
    process_sub_path(DEST, 'gamedata', myZip)
    process_sub_path(DEST, 'saves', myZip)

def process_sub_path(base_path, sub_path, zipfile):
    full_path = os.path.join(base_path, sub_path)
    for name in os.listdir(full_path):
        short_path = os.path.join(sub_path, name)
        if short_path.lower() in EXCEPT:
            full_name = os.path.join(base_path, sub_path, name)
            if os.path.isfile(full_name):
                zipfile.write(full_name, short_path, ZIP_DEFLATED)
            elif os.path.isdir(full_name):
                process_sub_path(base_path, short_path, zipfile)

if __name__ == '__main__':


Edited by Kerbart
Ugly sentence.

Share this post

Link to post
Share on other sites
This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this