Hi All,
I'm currently working on loading some data into Adobe Campaign Classic V7 which has been exported from a dataset in AEP. As AEP creates a new subfolder each time it exports an incremental file I'm finding it hard to automate the loading of these files in ACM due to not having a consistent location the files are placed.
The files exported from AEP Dataflow activity are placed directly on our Adobe Campaign SFTP. I would like to understand how I can find those files easily in campaign SFTP for loading.
I have Javascript already that lists the files present within a particular ACM SFTP Location, but would want to amend the code to list the folders present within that ACM location.
The code used to list files in a location is below. How can I amend this to list the sub-folders present in the provided location. I've tried various different codes and objects and each of them seem to not be available for use in ACM Javascript
---------------Code Start--------------------
---------------Code End---------------------
Solved! Go to Solution.
Views
Replies
Total Likes
Hi ALangridge,
I was able to get a piece of code from another colleague which does the job I needed.
The code is the below:
--------file operation on sftp from WF-----
var folder = new File('//home//');//change your dir here
logInfo('1')
if(!folder.isDirectory)
{
logInfo('not a dir');}
logInfo('2')
var sortListAlphabetically=true;
var ignoreCase = false;
for each(var subfolder in folder.list('*',sortListAlphabetically,ignoreCase))
{//change the directory filter here
logInfo('3')
logInfo('Found subfolder',subfolder.path);
if(!subfolder.isDirectory)
{continue;}
for each(var file in subfolder.list('*',sortListAlphabetically,ignoreCase))
{//change the file filter here
if(!file.isFile)
{
continue;}
logInfo('4')
logInfo('-found file:',file.fullName);
//file.remove();//uncomment to delete files
}
}
Thanks for looking into it though,
Appreciate the suggestions.
Ash
Bad news: I don't know of any way to work with directories via the File() class and methods.
Good news: When previously using AEP, our exports were all going to the same folder - it would just have a date stamp at the end of the name.
Annoying news: We're no longer using AEP, so I can't confirm specifically how this was achieved. But if you chase this up with the AEP team, you may end up with everything in a single file location!
From there a basic amendment to your code to check .lastModified and then maybe a .copyTo() and .remove() to move and archive the processed files will have you all good.
Views
Replies
Total Likes
Hi ALangridge,
I was able to get a piece of code from another colleague which does the job I needed.
The code is the below:
--------file operation on sftp from WF-----
var folder = new File('//home//');//change your dir here
logInfo('1')
if(!folder.isDirectory)
{
logInfo('not a dir');}
logInfo('2')
var sortListAlphabetically=true;
var ignoreCase = false;
for each(var subfolder in folder.list('*',sortListAlphabetically,ignoreCase))
{//change the directory filter here
logInfo('3')
logInfo('Found subfolder',subfolder.path);
if(!subfolder.isDirectory)
{continue;}
for each(var file in subfolder.list('*',sortListAlphabetically,ignoreCase))
{//change the file filter here
if(!file.isFile)
{
continue;}
logInfo('4')
logInfo('-found file:',file.fullName);
//file.remove();//uncomment to delete files
}
}
Thanks for looking into it though,
Appreciate the suggestions.
Ash
Oh gotcha! I just realised I was doing the same thing as you in your original code, using a "*.*" mask - which of course would ignore folders haha.
Views
Replies
Total Likes
Views
Likes
Replies