View Single Post
  #714  
Old 13.05.2019, 21:01
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
Default

Quote:
Originally Posted by sherbee View Post
Idea how to handle rename if file name already exists? Is there trigger or event to use? And what renaming plan would be best? Becaus if name exists script does not move.
One option would be to move the files to a timestamp based sub-folder.

Code:
// Move archive files after extraction
// Trigger: Archive Extraction Finished

var links = archive.getDownloadLinks() || [];
var timestamp = new Date().getTime();

links.forEach(function(link) {
    var filePath = getPath(link.getDownloadPath());
    filePath.moveTo(filePath.getParent().toString().replace("JD Downloads", "!TRASH!/" + timestamp));
});
Reply With Quote