Hi All,
Only been working with switch for a few months but I have an issue trying to pick all files in a named folder. The folders are dates, files are loaded in to the folders each day and the name of the folder is set to the corresponding day - ie 20190710. I have tested my pickup method by adding 20190710 into the regular expression option and the FTP element will pick up as expected but to make it automated I need to change the date every day so I have written the script below and added to the script expression.
function dateToYMD(date) {
var d = date.getDay();
var m = date.getMonth();
var y = date.getYear();
return '' + y + '' + (m<=9 ? '0' + m : m) + '' + (d <= 9 ? '0' + d : d);
}
var today = new Date();
var f1 = (dateToYMD(new Date(today.getYear(),today.getMonth(),today.getDay())));
var path = f1;
var path = '20190708'
job.log(2,"Todays Date %11, year %12, Month %13, day %14",[today,today.getYear(),today.getMonth(),today.getDay()]);
job.log(2,"Path set for file pick up %1",path);
if(job.getName() == path){
job.log(2,"Yep pick up files in this folder %1",job.getName());
path = job.getPath();
}
path;
As you can see I have a few values writing to the logs so I can see what is going on. I am try to pick all files in folder 20190708 as I have hard coded path to eliminate any coding issues from the function but it seems from the logs to output the correct values. I can even see a log that entry when it passes over the if statement but I am stumped why it will not download. Any help would be much appreciated.
FTP Receive Help
Re: FTP Receive Help
All good figured this out. My issue was that I wasn't returning a boolean value - returning job.getName() == path; did the trick.
Re: FTP Receive Help
All good figured this out. My issue was that I wasn't returning a boolean value - returning job.getName() == path; did the trick.