Created
December 17, 2019 02:04
-
-
Save fessehaye/75b5cca1e4ab0986d46a2883195c0d59 to your computer and use it in GitHub Desktop.
Sort Slippi files by matchup played
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os,sys,shutil | |
from slippi import Game | |
from tqdm import tqdm | |
slippiDir = 'C:\\Users\\Simon\\Desktop\\FM-v5.9-Slippi-r18-Win\\Slippi\\' | |
target = 'C:\\Users\\Simon\\Desktop\\slippi\\' | |
def getChars(players): | |
chars = [player.character.name for player in players] | |
chars.sort() | |
return "vs".join(chars) | |
def sortToDir(slippiFiles): | |
try: | |
for file in tqdm(slippiFiles): | |
game = Game(file) | |
MUs = getChars(game.start.players[:2]) | |
if os.path.exists(target+MUs) is False: | |
os.mkdir(target+MUs) | |
shutil.copy(file, target+MUs) | |
else: | |
shutil.copy(file, target+MUs) | |
except IOError as e: | |
print("Unable to copy file. %s" % e) | |
except: | |
print("Unexpected error:", sys.exc_info()) | |
try: | |
shutil.rmtree(target, ignore_errors=True) | |
slippiFiles = [slippiDir + f for f in os.listdir(slippiDir)] | |
print(str(len(os.listdir(slippiDir))) + " Replay Files in total") | |
print("Sorting Slippi Files for Matchups") | |
sortToDir(slippiFiles) | |
except: | |
print('Error while deleting directory') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment