JDownloader Community - Appwork GmbH
 

Reply
 
Thread Tools Display Modes
  #1  
Old 28.11.2024, 16:49
FBD's Avatar
FBD FBD is online now
Giga Loader
 
Join Date: Nov 2018
Location: https://web.libera.chat/#jDownloader
Posts: 96
Post Check if files in download list already exist and disable or remove links

This script checks if files in the download list already exist in their configured download folder (or additional folders) and disables or removes the links without having to start the downloads.

Script is intended to be triggered by a toolbar button named "FileCheck" which has to be added for the script to work.

Spoiler:

Code:
// Check if files in download list already exist and disable or remove link without starting downloads (FBD)
// Trigger : "Toolbar Button Pressed"
// Toolbar Button Name: "FileCheck"

// Uncomment if you know what you're doing
// disablePermissionChecks();

if (name == "FileCheck") {
    var myFilePackage = getAllFilePackages();
    var folders = [];
    var report = [];

    // Uncomment to ADDITIONALLY check if file exists in these folders
    // folders.push("/media/download","D:/Downloads","C:/Downloads2");

    var myDownloadLinks = getAllDownloadLinks();
    for (a = 0; a < myDownloadLinks.length; a++) {

        var link = myDownloadLinks[a];
        var myFilePackage = link.getPackage();
        var linkName = link.getName();
        
        var allfolders = folders;
        allfolders.push(myFilePackage.getDownloadFolder()); // regular download folder

        allfolders.forEach(function(folder) {
            // uncomment to ignore disabled links
            //if (!link.isEnabled()) return;

            var file = getPath(folder + "/" + linkName);
            if (!file.exists()) return;
        
            report.push("Package \"" + myFilePackage.getName()
                        + "\" Folder: \"" + folder + "\""
                        + "\" File: \"" + linkName + "\""
                        );

            // Deactivate Link
            link.setEnabled(false);
        
            // Uncomment to also remove link from download list
            // link.remove();
        });
    }
    
    // comment this if you don't want to see a report
    if (report.length > 0) {
        setAdvancedAlert(true);
        alert("The following links have been disabled because the files already exist:\n\n" + report.join("\n"));
    } else {
        alert("Check completed. No existing files found.");
    }
}


Direct download: raw.githubusercontent.com/FarBeyondDriven/JDscripts/refs/heads/main/CheckFilesExists.js
__________________
irc.libera.chat #jDownloader web.libera.chat/#jDownloader
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT +2. The time now is 19:12.
Provided By AppWork GmbH | Privacy | Imprint
Parts of the Design are used from Kirsch designed by Andrew & Austin
Powered by vBulletin® Version 3.8.10 Beta 1
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.