Skip to content

Instantly share code, notes, and snippets.

@Langerz82
Last active February 1, 2021 08:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Langerz82/2c584a3deb2d37b52540ac490bea996b to your computer and use it in GitHub Desktop.
Save Langerz82/2c584a3deb2d37b52540ac490bea996b to your computer and use it in GitHub Desktop.
LPL File Organiser for RetroArch Arcade ROMS. Linux.
<!DOCTYPE HTML>
<!--
This file is part of lplorganiser.js.
License: GPL3.
Author: Langerz82.
Copyright: Langerz82 2020.
-->
<html>
<head>
<script src="lplorganiser.js"></script>
</head>
<body>
<textarea id="emupaths" cols="100" rows="19" readonly="true">
</textarea>
<textarea id="lpltext" cols="100" rows="19" readonly="true">
</textarea>
</body>
</html>
/*
* This file read reads from lpl arcade files and generates the
* commands and new lpl file for moving roms into the proper
* sub-directories. You could modify this code to include non-arcade
* rom lpl paths.
*
* This file is part of lplorganiser.js.
* License: GPL3.
* Author: Langerz82.
* Copyright: Langerz82 2020.
*/
// url string like 'lplorganiser.html?lpln=0' etc.
// make sure you enter the correct rom path.
const romPath = "insert_rom_path";
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
const lpln = urlParams.get('lpln');
emus = new Object();
emus.emuName = new Array (
"FBNeo - Arcade Games",
"MAME 2000",
"MAME 2003",
"MAME 2003-Plus"
);
emus.emuDir = new Array (
"fba",
"mame2000",
"mame2003",
"mame2003-plus"
);
function lplready (lpldata)
{
//console.log(lpldata);
htmlPaths.value = "";
for (var it = 0; it < lpldata.items.length; ++it)
{
var lplitempath = lpldata.items[it].path;
var path = lplitempath.substr(0,lplitempath.lastIndexOf('/'));
var romName = lplitempath.substr(lplitempath.lastIndexOf('/')+1);
if (path == romPath)
{
var newfile = emus.emuDir[lpln] +
"/" + romName;
htmlPaths.value += "sudo mv \"" + romName + "\" ";
htmlPaths.value += "\"" + newfile + "\"\n";
lpldata.items[it].path = romPath + "/" + newfile;
}
var lplout = JSON.stringify(lpldata, null, 4);
lpltext.value = lplout;
}
}
function lplload ()
{
if (lpln >= 0 && lpln < emus.emuName.length)
{
fetch(emus.emuName[lpln]+'.lpl')
.then(response => {
return response.json();
})
.then(data => lplready(data));
}
}
document.addEventListener("DOMContentLoaded", (event) => {
htmlPaths = document.getElementById("emupaths");
lpltext = document.getElementById("lpltext");
lplload();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment