JDownloader Community - Appwork GmbH
 

Reply
 
Thread Tools Display Modes
  #21  
Old 23.10.2020, 17:04
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,484
Default

Quote:
Originally Posted by dbrown1986 View Post
... Somehow I broke it.
Missing "{" bracket:

if (link.finished) {var destinationFolder ...

Best way to avoid such errors are to add/test it in GUI (Click "Test compile" to check for syntax errors) and then add it to headless.
Reply With Quote
  #22  
Old 24.10.2020, 01:52
dbrown1986 dbrown1986 is offline
Junior Loader
 
Join Date: Oct 2020
Posts: 11
Default

Quote:
Originally Posted by mgpai View Post
Yes. It is also possible to use eventscripter method to delete the source file if/after it is successfully copied.

Code:
// Move downloaded files to user-specified folder and remove the link from download list
// Trigger: A Download Stopped

if (link.finished) {
    var destinationFolder = getPath("/home/seedit4me/drive/debrid/" + link.package.name);
    var copied = getPath(link.downloadPath).copyTo(destinationFolder);

    if (copied) {
        getPath(link.downloadPath).delete()
        link.remove();
    }
}
I've tried. I copied this without changing a damn thing. Inputted it into the GUI, then opened the script.json file and parsed that through JSON Pretty to make sure that everything was okay and the script still won't work. Not on linux and now not in the windows GUI. I'm assuming there's just too many environment variables from the OS itself that are changing. It's too frustrating. I have spent the better part of two weeks trying to get this to function, and just when I feel like I'm making progress; everything rolls back. I give up. Thanks anyways guys.
Reply With Quote
  #23  
Old 24.10.2020, 06:38
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,484
Default

Quote:
Originally Posted by dbrown1986 View Post
... the script still won't work.
You can find me in JD Chat for online assistance with it:
Code:
kiwiirc.com/nextclient/irc.freenode.net/#jdownloader
Reply With Quote
  #24  
Old 26.10.2020, 18:55
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 76,897
Default

@mgpai: thanks for the hint. good sight

@dbrown1986: The script doesn't care about "environment variables" and yes, the previous post shows the missing bracket. I've just tested the exact same script (different path) and working fine.
see pastebin.com/RmHZPg3F
__________________
JD-Dev & Server-Admin
Reply With Quote
  #25  
Old 09.06.2022, 07:58
xefeg xefeg is offline
JD Alpha
 
Join Date: Oct 2019
Posts: 24
Default

Quote:
Originally Posted by mgpai View Post
Code:
// Move downloaded files to user-specified folder
// Trigger: A Download Stopped

if (link.finished) {
    var destinationFolder = "/home/";
    getPath(link.downloadPath).moveTo(destinationFolder);
}
Is there anyway to add filesize into the argument?
eg. move files which are less than 999 MB.
Reply With Quote
  #26  
Old 09.06.2022, 10:15
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 76,897
Default

@xefeg: try
Quote:
if (link.finished && link.bytesTotal > -1 && link.bytesTotal < (999*1024*1024)) {
__________________
JD-Dev & Server-Admin
Reply With Quote
  #27  
Old 09.06.2022, 10:59
xefeg xefeg is offline
JD Alpha
 
Join Date: Oct 2019
Posts: 24
Default

Quote:
Originally Posted by Jiaz View Post
@xefeg: try
Also, I use Packagizer to download all rapidgator links to FOLDER A. Is there anyway to move only that Folder A to a new folder?
The below code does not seem to work

Quote:
if (link.finished) {
var destinationFolder = "J:/Folder A/";
var downloadPath = "J:/Folder B/";
getPath(downloadPath).moveTo(destinationFolder);
}
Reply With Quote
  #28  
Old 09.06.2022, 11:02
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 76,897
Default

@xefeg: I'm sorry but can you try to explain better? after a single link is finished, you cannot move the folder. do you want to move the finished file to folder B ?
__________________
JD-Dev & Server-Admin
Reply With Quote
  #29  
Old 09.06.2022, 11:05
xefeg xefeg is offline
JD Alpha
 
Join Date: Oct 2019
Posts: 24
Default

Quote:
Originally Posted by Jiaz View Post
@xefeg: I'm sorry but can you try to explain better? after a single link is finished, you cannot move the folder. do you want to move the finished file to folder B ?
Yes, Finished file to a new Folder.

So using Packagizer, There is a custom folder for all files downloaded from RG.
After this download is finished from RG custom folder, I wanted to move the downloaded files to a new folder.

My default download folder for all files is @Jdownloader folder. Rapidgator folder is @RG folder, So, I basically wanted to move the files from @RG Folder to a @NewFolder
Reply With Quote
  #30  
Old 09.06.2022, 11:39
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 76,897
Default

@xefeg: and why move after download? why not directly download to correct folder?
see here for example https://board.jdownloader.org/showpo...9&postcount=22
Quote:
var filepath=getPath(link.downloadPath);
filepath contains the path to the finished file
__________________
JD-Dev & Server-Admin
Reply With Quote
  #31  
Old 09.06.2022, 12:00
xefeg xefeg is offline
JD Alpha
 
Join Date: Oct 2019
Posts: 24
Default

Quote:
Originally Posted by Jiaz View Post
why move after download? why not directly
Because the program I used which monitor the downloaded folder does not detect anything. It detects only when the files are moved.

It is still not working, It seems like all the files inside "J:/JJ" are moved which is the default download folder. I need to move the files which are downloaded into "J:/JJ/RG/" to the "J:/JJ/RGMove/".

Quote:
// Move downloaded files to user-specified folder
// Trigger: A Download Stopped

if (link.finished) {
var downloadPath = "J:/JJ/RG/";
var filepath=getPath(link.downloadPath);
var destinationFolder = "J:/JJ/RGMove/";
getPath(filepath).moveTo(destinationFolder);
}

Last edited by xefeg; 09.06.2022 at 12:04.
Reply With Quote
  #32  
Old 09.06.2022, 12:19
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 76,897
Default

Quote:
Originally Posted by xefeg View Post
Because the program I used which monitor the downloaded folder does not detect anything. It detects only when the files are moved.

It is still not working, It seems like all the files inside "J:/JJ" are moved which is the default download folder. I need to move the files which are downloaded into "J:/JJ/RG/" to the "J:/JJ/RGMove/".
I'm sorry but I don't understand. What do you mean by *all the files inside JJ are moved*? So the script works? this script does not check on the folder, it moves ALL files as the if condition only check if the download is finished
__________________
JD-Dev & Server-Admin
Reply With Quote
  #33  
Old 09.06.2022, 12:20
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 76,897
Default

Quote:
Originally Posted by xefeg View Post
Because the program I used which monitor the downloaded folder does not detect anything. It detects only when the files are moved.
can you tell me what program that is?
__________________
JD-Dev & Server-Admin
Reply With Quote
  #34  
Old 09.06.2022, 12:23
xefeg xefeg is offline
JD Alpha
 
Join Date: Oct 2019
Posts: 24
Default

Quote:
Originally Posted by Jiaz View Post
I'm sorry but I don't understand. What do you mean by *all the files inside JJ are moved*? So the script works? this script does not check on the folder, it moves ALL files as the if condition only check if the download is finished
Basically, I have a Packagizer which downloads all the files from Rapidgator links to the RG folder. Other links go to the default download directory.
I wanted to move the files from the RG folder to a new folder but the script seems to move all files whether its in the RG folder or not.
Reply With Quote
  #35  
Old 09.06.2022, 12:25
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,484
Default

Quote:
Originally Posted by xefeg View Post
It is still not working,
Code:
/*
    Move downloaded files
    Trigger: A Download Stopped 
*/

if (link.finished) {
    var curFolder = link.package.downloadFolder;
    var newFolder = curFolder.replace("/JJ/RG/", "/JJ/RGMove/");

    newFolder != curFolder && getPath(link.downloadPath).moveTo(newFolder);
}
Reply With Quote
  #36  
Old 09.06.2022, 12:37
xefeg xefeg is offline
JD Alpha
 
Join Date: Oct 2019
Posts: 24
Default

Quote:
Originally Posted by mgpai View Post
Code:
/*
    Move downloaded files
    Trigger: A Download Stopped 
*/

if (link.finished) {
    var curFolder = link.package.downloadFolder;
    var newFolder = curFolder.replace("/JJ/RG/", "/JJ/RGMove/");

    newFolder != curFolder && getPath(link.downloadPath).moveTo(newFolder);
}
Hello Sir, it still does not move. The downloaded files remains at "/JJ/RG/"
Reply With Quote
  #37  
Old 09.06.2022, 12:41
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,484
Default

Quote:
Originally Posted by xefeg View Post
Hello Sir, it still does not move. The downloaded files remains at "/JJ/RG/"
Code:
Try replacing "/" with "\\".
Reply With Quote
  #38  
Old 09.06.2022, 12:50
xefeg xefeg is offline
JD Alpha
 
Join Date: Oct 2019
Posts: 24
Default

Quote:
Originally Posted by mgpai View Post
Code:
Try replacing "/" with "\\".
Thanks a lot. Worked .:w00t:
Reply With Quote
  #39  
Old 09.06.2022, 13:00
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 76,897
Default

@mgpai: with next core update you can access FilePath.getPathSeparator
which will return / or \ depending on current OS
__________________
JD-Dev & Server-Admin
Reply With Quote
  #40  
Old 09.06.2022, 13:07
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,484
Default

Quote:
Originally Posted by Jiaz View Post
@mgpai: with next core update you can access FilePath.getPathSeparator
which will return / or \ depending on current OS
Thanks @Jiaz.
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 06:53.
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 - 2022, Jelsoft Enterprises Ltd.