Skip to content

Instantly share code, notes, and snippets.

@NikhilNarayana
Last active May 7, 2019 06:46
Show Gist options
  • Save NikhilNarayana/2d6dfbfdc3656fbb2f13091bfe7a11a0 to your computer and use it in GitHub Desktop.
Save NikhilNarayana/2d6dfbfdc3656fbb2f13091bfe7a11a0 to your computer and use it in GitHub Desktop.
SLP file sorter. Windows executable can be found here: https://drive.google.com/file/d/1JISMLoQZ2pSi0w4dH0tB-gwuI4KemYjv/view?usp=sharing
const { default: SlippiGame } = require('slp-parser-js');
const path = require('path');
const fs = require('fs');
var inputPath = './input/';
var outputPath = './output/';
function sortSLP() {
files = fs.readdirSync(inputPath);
files.forEach((file) => {
let filep = path.join(inputPath, file);
let game = new SlippiGame(filep);
let metadata = game.getMetadata();
let settings = game.getSettings();
let nickname = metadata.consoleNick || "unknown";
if (settings.isTeams) {
fs.mkdir(path.join(outputPath, nickname, "/doubles/"), { recursive: true }, (err) => {
fs.rename(filep, path.join(outputPath, nickname, "/doubles/", file), (err) => {return;});
});
} else {
fs.mkdir(path.join(outputPath, nickname, "/singles/"), { recursive: true }, (err) => {
fs.rename(filep, path.join(outputPath, nickname, "/singles/", file), (err) => {return;});
});
}
});
}
console.time("sorting");
sortSLP();
console.timeEnd("sorting");
@NikhilNarayana
Copy link
Author

NikhilNarayana commented May 7, 2019

const { default: SlippiGame } = require('slp-parser-js');
const path = require('path');
const fs = require('fs');

var inputPath = './input/';
var outputPath = './output/';

function sortSLP() {
	files = fs.readdirSync(inputPath);
	files.forEach((file) => {
		let filep = path.join(inputPath, file);
		let game = new SlippiGame(filep);

		let metadata = game.getMetadata();
		let settings = game.getSettings();
		let nickname = metadata.consoleNick || "unknown";
		fs.mkdir(path.join(outputPath, nickname), { recursive: true }, (err) => {
			fs.rename(filep, path.join(outputPath, nickname, file), (err) => {return;});
		});
	});
}
console.time("sorting");
sortSLP();
console.timeEnd("sorting");

a new addition to the zip is this version of the sorter that sorts in the format that Fizzi requires for slippi.gg

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment