View Single Post
  #1809  
Old 05.08.2021, 12:45
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
Default

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) {};
    })
}
Reply With Quote