|
#1
|
|||
|
|||
![]()
I'm hoping to move packages to a separate folder after completion. I know the feature does not exist in JDownload 2. I found a script at https://board.jdownloader.org/showpo...7&postcount=29 .
However, it moves all download files to a single directory, without preserving any of the original directory structure. Is there any way to fix that ? If this was C or C++, I wouldn't have any issue doing it myself, but I'm unfortunately useless with JavaScript, and ChatGPT doesn't seem sufficiently versed in EventScripter to make the change for me, despite the very clear prompt I gave it. It keeps producing code using identifiers that are not part of EventScripter. |
#2
|
|||
|
|||
![]() Code:
/* move finished trigger : jdownloader started */ getAllFilePackages().forEach(function(package) { if (package.finished) { var curFolder = package.downloadFolder; var newFolder = curFolder.replace("\\downloading", "\\finished"); if (curFolder != newFolder) { package.downloadFolder = newFolder; } } }) Should work fine, but better run/try it on test install first. |
#3
|
|||
|
|||
![]()
Hi,
Thanks for your answer. Response below. Quote:
I tried it, as the following : Code:
/* move finished trigger : jdownloader started */ getAllFilePackages().forEach(function(package) { if (package.finished) { var curFolder = package.downloadFolder; var newFolder = curFolder.replace("d:\\Downloads\\JDownloader", "d:\\Downloads\\Complete"); if (curFolder != newFolder) { package.downloadFolder = newFolder; } } }) Thanks again. Last edited by rabidman; 10.12.2024 at 13:55. |
#4
|
|||
|
|||
![]()
Only files which were downloaded by JD into that folder (and still exist there) will be moved. Files subsequently copied or extracted to that folder will not be moved.
This is by design, since multiple packages can share a (that) common download folder and it might contain files belonging to other packages. I haver read your reply in the other thread. You can test/use this to to move the entire folder, keeping in mind it moves ALL the files/folders in it. Code:
/* demo trigger : click test run in top panel */ var myPackage = getPath("d:\\downloads\\jdownloader\\myPackage"); var complete = "d:\\downloads\\complete"; var moved = getPath(myPackage).moveTo(complete); alert(moved); If you prefer, you can also use CLI commands in eventscripter (using callSync/callAsync) to do the same. |
#5
|
||||
|
||||
![]()
Hi,
Thanks again for your response. More inline. Quote:
And why would extraction cause an issue, as long as the extraction is performed inside the package folder ? Quote:
Or alternately, perform the move only after the last package with a shared folder name has completed downloading ? Quote:
Also, what would be the correct trigger to use ? Thanks again ! Last edited by rabidman; 10.12.2024 at 10:32. |
#6
|
|||
|
|||
![]() Quote:
Quote:
Quote:
It would not be wise to 'set' the new path while extraction is active. So, the script uses 'jdownloader started' trigger, at which point extraction presumably will have been completed. A better option is to create a "toolbar button pressed" and manually run the script by clicking the button. Point to note: "moveTo" is a filePath object method, when used to move files will sever all connection between the downloadPath and the file on disk. The link in the download list may no longer point to the correct location on disk Recommedation:
|
#7
|
|||
|
|||
![]() Quote:
Thanks. |
#8
|
||||
|
||||
![]()
@mgpai: see here for desired behaviour, https://board.jdownloader.org/showpo...22&postcount=5
__________________
JD-Dev & Server-Admin |
#9
|
|||
|
|||
![]()
|
#10
|
|||
|
|||
![]()
No to both.
|
#11
|
|||
|
|||
![]()
Script:
Code:
/* change download folder trigger : interval (set interval in ms as desired, e.g. 3600000 for 1 hour) */ getAllFilePackages().forEach(function(package) { if (package.finished && !package.archives.length) { var curFolder = package.downloadFolder var newFolder = curFolder.replace("\\jdownloader\\", "\\complete\\"); if (curFolder != newFolder) { package.downloadFolder = newFolder callAPI("downloadsV2", "removeLinks", [], [package.UUID]); } } }) Archive extractor settings: ![]() Workflow:
Please try on test install first. Last edited by mgpai; 11.12.2024 at 08:16. Reason: Updated script |
#12
|
|||
|
|||
![]()
Thank you ! This seems to be working, at least initially. I'll report if I find any issues.
|
#13
|
||||
|
||||
![]()
Correct me if I'm wrong but at least for packages with only archives && when auto extract is enabled, you could use a Packagizer rule instead of a script or alternatively just define a custom global extraction path.
__________________
JD Supporter, Plugin Dev. & Community Manager
Erste Schritte & Tutorials || JDownloader 2 Setup Download |
#14
|
|||
|
|||
![]() Quote:
Best solution, suggested in one of the posts above. |
#15
|
||||
|
||||
![]() Quote:
This is a huge design flaw which a lot of users have asked us to properly implement. It looks like the use case "move finished downloads to another place than the one they were initially downloaded to" is something that a lot of users want.
__________________
JD Supporter, Plugin Dev. & Community Manager
Erste Schritte & Tutorials || JDownloader 2 Setup Download |
#16
|
|||
|
|||
![]()
Spoke too soon. Standalone files, ie. in the multiple virtual "Various files" packages, do not get moved.
Last edited by rabidman; 12.12.2024 at 10:44. |
#17
|
|||
|
|||
![]() Quote:
Since the archive part is handled by the archive extractor, the script will have only to deal with non-archive files. Also, since you are using a pattern to save and move files, it is also possible to just move the non-archive files to the new location using a pattern. Code:
/* move finished file trigger : download stopped */ if (link.finished && !link.archive) { var src = getPath(link.downloadPath); var packageName = link.package.name; var dest = getPath("d:/downloads/complete/" + packageName); var moved = src.moveTo(dest); if (moved) { link.remove(); getPath(src.parent).delete(); } else { alert(src + " was not moved."); } } Last edited by mgpai; 12.12.2024 at 12:20. |
#18
|
|||
|
|||
![]() Quote:
|
#19
|
|||
|
|||
![]()
If necessary, additanol alerts when move fails can be added. e.g 'src file does not exist' and 'dest file exists".
|
#20
|
|||
|
|||
![]() Quote:
I would prefer fewer pop-ups, if possible. Ideally, comparing the files, and just deleting the source if it's identical to the destination, with an alert only if it's different, or the move fails. |
#21
|
||||
|
||||
![]()
Instead of popups you could also just write all possible alerts into one text-file.
If in the end, you got that error text-file left in your folder, you can look into it without unnerving alerts.
__________________
JD Supporter, Plugin Dev. & Community Manager
Erste Schritte & Tutorials || JDownloader 2 Setup Download |
#22
|
|||
|
|||
![]()
I have gotten numerous problems with this script.
1. thousands upon thousands of files that did not get moved. That is a lot of popups to dismiss. I had ChatGPT write an Autohotkey script to dismiss them. But this is not a solution. I'm not sure of the root cause, or how to solve the problem. 2. unwanted renaming of files and directories I have noticed that files and directories that are downloaded have very different names in the target "Complete" directory. I don't understand why that is. The script should move files, but should not rename them, or rename the directory structure. 3. move is not atomic at the package level I really want the package to be moved all at once when it is complete. I do not want to move one file at a time. This is so that I can manually move the folders to their final destination, without having to manually check in JDownloader whether there are still files pending download for that package. This is extremely tedious when there are dozens or even hundreds of folders, some of which can take days, weeks or even months to download due to hoster bandwidth limitations. Ie. there is never a time when my download list is empty, and I can confidently move anything out of Complete without any risk of race condition. 4. problems with DLC I ran into a serious problem with JDownloader. It would no longer exit. It had to be killed from Windows Task manager every time. I saved my settings and my downloads into a DLC. When resuming downloads, the script got the following error stack : net.sourceforge.htmlunit.corejs.javascript.EcmaError: TypeError: Cannot read property "name" from null (#8) at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3935) at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3919) at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3944) at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.typeError2(ScriptRuntime.java:3960) at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.undefReadError(ScriptRuntime.java:3971) at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.getObjectProp(ScriptRuntime.java:1519) at net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpretLoop(Interpreter.java:1243) at script(:8) at net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpret(Interpreter.java:798) at net.sourceforge.htmlunit.corejs.javascript.InterpretedFunction.call(InterpretedFunction.java:105) at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.doTopCall(ContextFactory.java:411) at org.jdownloader.scripting.JSHtmlUnitPermissionRestricter$SandboxContextFactory.doTopCall(JSHtmlUnitP ermissionRestricter.java:134) at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3286) at net.sourceforge.htmlunit.corejs.javascript.InterpretedFunction.exec(InterpretedFunction.java:115) at net.sourceforge.htmlunit.corejs.javascript.Context.evaluateString(Context.java:1361) at org.jdownloader.extensions.eventscripter.ScriptThread.evalUNtrusted(ScriptThread.java:346) at org.jdownloader.extensions.eventscripter.ScriptThread.executeScipt(ScriptThread.java:194) at org.jdownloader.extensions.eventscripter.ScriptThread.run(ScriptThread.java:174) If I add new downloads with a URL, I don't get this error stack. Last edited by rabidman; 19.01.2025 at 05:28. |
#23
|
||||
|
||||
![]()
@rabidman:
1.) instead of spending time to write autohotkey to auto dismiss the alerts, you should better spend time and find out why moving fails that often for you. Are source and destination on same drive/location? maybe destination file already exists? you should ask for help to modify script to 1.) retry and 2.) provide better logs on why it might have failed to move 2.) what script exactly are you using? the one shown in post 33 does not have any rename at all, so the different filename must be already in list before 3.) requires a total different sort of script as it has to wait for all links to reach sort of finished/final state and wait for any extractions to finish Why not leave files at place and auto remove finished/downloaded files from list and setup a script that starts once the package is removed (no more links in it) and then start moving the files? That would be much easier to maintain as the package in JDownloader will become smaller and smaller while downloading and either its empty = finished = can move or some errors that you have to check first 4.) I've answered in your other thread. Quote:
Quote:
That would also explain the Quote:
__________________
JD-Dev & Server-Admin Last edited by Jiaz; 20.01.2025 at 03:10. |
#24
|
|||
|
|||
![]()
This has happened many times in the last week. I captured it in a log today :
27.01.25 11.19.40 <--> 27.01.25 11.33.08 jdlog://9858411370661/
__________________
Ph’nglui mglw’nafh Cthulhu R’lyeh wgah’nagl fhtagn. |
#25
|
||||
|
||||
![]()
@rabidman: You have a script in use in Eventscripter that does not correctly handle error.
Can you please tell us what script (link to script) or copy of the script you have active in your JDownloader, then we can check/help to fix it
__________________
JD-Dev & Server-Admin |
#26
|
||||
|
||||
![]()
Why a new thread?
I guess your post is still about the topic "Moving packages and files after completion"?
__________________
JD Supporter, Plugin Dev. & Community Manager
Erste Schritte & Tutorials || JDownloader 2 Setup Download |
#27
|
|||
|
|||
![]() Quote:
I guess I'm confused by the UI. Is there no way to disable a specific script while keeping Eventscripter enabled ? For example, if I have 3 different scripts, can I just enable 1 and leave the other 2 disabled ? Or do I have to delete the scripts I'm not using ?
__________________
Ph’nglui mglw’nafh Cthulhu R’lyeh wgah’nagl fhtagn. |
#28
|
||||
|
||||
![]()
Merged same topic threads.
Quote:
Disabled scripts will not be executed anymore so yes, you can have multiple scripts and only enable the ones you really want to use.
__________________
JD Supporter, Plugin Dev. & Community Manager
Erste Schritte & Tutorials || JDownloader 2 Setup Download |
![]() |
Thread Tools | |
Display Modes | |
|
|