View Single Post
  #24  
Old 05.02.2020, 14:47
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,545
Default

Quote:
Are ... names with extensions ... in a txt file ... usable for the new script?
Code:
// Skip download link, if filename exists in the user-spcified list
// To download the file (prevent skipping), remove "#duplicatefile" from comment
// Trigger required: A Download Started

var fileNamesList = "c:/myFolder/fileslist.txt"; // < Set path to text file which contain the file names. Use "\\" or "/" as path separators.
var dupeFilecheck = link.getProperty("dupeFileCheck");
var linkName = link.getName();
var comment = link.getComment() || "";
var skipLink = function() {
    link.setSkipped(true);
    alert("Download Skipped: File \"" + linkName + "\" is present in files list.");
}

if (dupeFilecheck) {
    if (comment.indexOf("#duplicatefile") > -1) skipLink();
} else {
    var fileNames = readFile(getPath(fileNamesList)).trim().split("\r\n");

    fileNames.some(function(fileName) {
        if (linkName == fileName.trim()) {
            var text = "#duplicatefile";
            comment = comment ? text + " " + comment : text;
            link.setComment(comment);
            skipLink();
            return true;
        }
    })

    link.setProperty("dupeFileCheck", true);
}

I've quoted parts of text from your email for reference, without your permission. Hope it's OK.

Last edited by mgpai; 10.02.2020 at 07:00. Reason: Modified script to remove leading and trailing spaces from 'fileName'
Reply With Quote