View Single Post
  #2008  
Old 05.11.2021, 05:17
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,553
Default

Quote:
Originally Posted by KlaraBlik View Post
... I would like to move only certain file types (e.g. .mp3) after successful extraction to a new folder. How do I have to amend this script?
This script will preserver folder structure. To move all the files to a single folder you can also just use a packagizer rule.

Code:
/*
    Move extracted files
    Trigger: Archive extraction finished
*/

var source = "C:\\Downloads";
var destination = "C:\\Finished";
var fileTypes = ["mp3", "ex1", "ex2"];

archive.extractedFilePaths.forEach(function(filePath) {
    if (fileTypes.indexOf(filePath.extension) > -1) {
        var newFolder = filePath.parent.toString().replace(source, destination);
        filePath.moveTo(newFolder);
    }
})
Reply With Quote