View Single Post
  #47  
Old 10.02.2020, 20:02
Fetter Biff Fetter Biff is offline
JD Legend
 
Join Date: Oct 2014
Posts: 945
Default

Quote:
Can be disabled. In the script, below link.setComment(comment); add link.setEnabled(false);.
Thank you. Looks like this now:
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 = "I:\\jD-Downloads\\jD-Dummies.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); //To disable the link instead of skipping it, replace link.setSkipped(true); with link.setEnabled(false); in both the scripts.
    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);
            link.setEnabled(false);
            skipLink();
            return true;
        }
    })

    link.setProperty("dupeFileCheck", true);
}
Quote:
If you just want to find which links are marked as duplicate, use the search bar in the bottom toolbar. Select search by comment and add #duplicatelink in the search field.
That is great, thank you!
Reply With Quote