View Single Post
  #806  
Old 26.06.2019, 08:51
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 611
Default

Quote:
Originally Posted by the Dark View Post
/as/example/deletefilesfolder //<--- path to there only watchfolder files get downloaded (manually downloaded files should stay in another path)

if the files got downloaded I want to delete them after about 5 minutes to keep the drive clean (needs to be a seperate folder)
Delete files at specified interval:
Code:
// Delete downloaded files from user-specified folder, at user-specified interval.
// Trigger : Interval (300000)

var myFolder = "/as/example/deletefilesfolder"; // <- case-sensitive

getAllDownloadLinks().forEach(function(link) {
    if (!link.isFinished()) return;
    var file = getPath(link.getDownloadPath());
    if (!file.exists()) return;
    var downloadFolder = link.getPackage().getDownloadFolder();
    if (downloadFolder == myFolder) file.delete();
})

Delete files immediately after downloading (Recommended):
Code:
// Delete downloaded files from user-specified folder, immediately after it's been downloaded.
// Trigger : A Download Stopped

var myFolder = "/as/example/deletefilesfolder"; // <- case-sensitive

if (link.isFinished()) {
    var downloadFolder = link.getPackage().getDownloadFolder();
    if (downloadFolder == myFolder) {
        var file = getPath(link.getDownloadPath());
        file.delete();
    }
}
Reply With Quote