View Single Post
  #721  
Old 14.05.2019, 12:51
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 627
Default

Quote:
Originally Posted by sherbee View Post
Thank you for idea. But I like complicated.
Here is a new script, but if you need help to troubleshoot/fix yours, contact me in JD Chat.

Code:
// Move archive files after extraction
// Trigger: Archive Extraction Finished

var links = archive.getDownloadLinks() || [];
var destinationFolder = "C:/sherbee/check";

links.forEach(function(link) {
    var filePath = getPath(link.getDownloadPath());
    var i = 0;

    while (getPath(destinationFolder + "/" + filePath.getName()).exists()) {
        i++;
        newPath = getPath(link.getDownloadPath().toString().replace(/(.+)(\..+)/, "$1" + i + "$2"));
        getPath(filePath).renameTo(newPath);
        filePath = newPath;
    }

    filePath.moveTo(destinationFolder);
});
Reply With Quote