Code:
/*
Remove orphaned archive settings files from "cfg/archives" folder
Trigger : Toolbar button pressed
Customize toolbar > Add a new "Eventscripter Trigger" button > Rename it to "Remove archive settings files"
*/
if (name == "Remove archive settings files") {
var ids = [];
getAllFilePackages().forEach(function(package) {
package.archives.forEach(function(archive) {
ids.push(archive.settingsID);
})
})
getPath(JD_HOME + "/cfg/archives").children.forEach(function(filePath) {
try {
var id = filePath.toString().match(/v2_(.+)\.json/)[1];
if (ids.indexOf(id) == -1) {
filePath.delete();
}
} catch (e) {};
})
}