View Single Post
  #1532  
Old 09.09.2020, 09:07
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,000
Default

Requested by dex1983 (IRC)

Code:
/*
    On package finished, if the package does not contain archives, move files to user-specified location
    Trigger: Package finished
*/

var myFolder = "/path/to/folder"; //<- set destination path

if (!package.getArchives().length) {
    package.getDownloadLinks().forEach(function(link) {
        getPath(link.downloadPath).moveTo(myFolder);
    })
}

Code:
/*
    On package finished, move files to user-specified location
    Trigger: Archive extraction finished
*/

var myFolder = "/path/to/folder", //<- set destination path
    links = archive.getDownloadLinks();

if (links) {
    var package = links[0].package;

    if (package.finished) {
        package.getDownloadLinks().forEach(function(link) {
            if (link.getArchive()) {
                archive.getExtractedFilePaths().forEach(function(file) {
                    file.moveTo(myFolder);
                })
            } else {
                getPath(link.downloadPath).moveTo(myFolder);
            }
        })
    }
}
Reply With Quote