

#1
|
|||
|
|||
![]()
A script that removed all of the (really) empty folders (without a single file, even a 0 byte file) in the default download folder each time when closing / restarting JD would be good.
After some time there are pretty many folders in the default download folder, so it would be good / clearer removing them. https://board.jdownloader.org/showth...191#post544191
__________________
Aktuelles Windows |
#2
|
|||
|
|||
![]() Code:
/* delete empty folders trigger : jdownloader started */ var downloadFolder = callAPI( "config", "get", "org.jdownloader.settings.GeneralSettings", null, "DefaultDownloadFolder" ) getPath(downloadFolder).children.forEach(function(item) { item.directory && item.delete(); }) |
#3
|
|||
|
|||
![]()
Very fast, thank you very, very much!
__________________
Aktuelles Windows |
#4
|
|||
|
|||
![]()
Sorry, I cannot get it working, what is wrong here:
Spoiler:
![]() ![]() So there is no folder removed.
__________________
Aktuelles Windows Last edited by pspzockerscene; 12.02.2025 at 11:38. Reason: Added SPOILER tag |
#5
|
|||
|
|||
![]()
To test the script, create an empty folder in the JD default download directory, then click 'test run' in the script top panel, and see if that folder you created is removed.
|
#6
|
|||
|
|||
![]()
OK, thank you, nothing is removed.
__________________
Aktuelles Windows |
#7
|
||||
|
||||
![]()
@Dockel: how do you test it? click the *Test Run" button.
Script will look look into default download folder (from your settings) and only delete empty folders
__________________
JD-Dev & Server-Admin |
#8
|
|||
|
|||
![]() Quote:
__________________
Aktuelles Windows |
#9
|
||||
|
||||
![]()
Here is my assumption on what's going on:
You got the setting "subfolder by package name" activated so your path ends with dynamic tag "/<jd:packagename>". This will result in the script failing as the path is now wrong. I've created another version of the script with the following changes: - Remove trailing "<jd:packagename>" from path - Throw exception if after path correction, path still does not exist (e.g. due to other dynamic tags used in path) Code: Code:
/* delete empty folders trigger : jdownloader started */ var downloadFolder = callAPI( "config", "get", "org.jdownloader.settings.GeneralSettings", null, "DefaultDownloadFolder" ); // Remove dynamic tag "<jd:packagename>" from the end of the path if present if (downloadFolder.endsWith("<jd:packagename>")) { downloadFolder = downloadFolder.substring(0, downloadFolder.length - "<jd:packagename>".length); } // Check if the path exists, otherwise throw an exception if (!getPath(downloadFolder).exists()) { throw new Error("Download folder does not exist: " + downloadFolder); } // Delete all subdirectories inside the download folder getPath(downloadFolder).children.forEach(function(item) { item.directory && item.delete(); });
__________________
JD Supporter, Plugin Dev. & Community Manager
Erste Schritte & Tutorials || JDownloader 2 Setup Download |
#10
|
|||
|
|||
![]()
Thank you very much! I will try at next occasion.
Quote:
Quote:
Ja, geht, gerade probiert.
__________________
Aktuelles Windows Last edited by Dockel; 13.02.2025 at 00:19. |
#11
|
||||
|
||||
![]() Quote:
c:\test -> exists and script can list the content and look for empty folders to delete c:\test\<jd:packagename> -> does not exist on disk, nothing to list, nothing to delete ![]() Perfekt! @Dockel: Du solltest im Default Ordner keine Platzhalter verwenden/haben, sondern dafür den Paketverwalter nutzen
__________________
JD-Dev & Server-Admin |
#12
|
|||
|
|||
![]()
Okay, ich verstehe.
Quote:
Vielen Dank!
__________________
Aktuelles Windows |
![]() |
Thread Tools | |
Display Modes | |
|
|