Expand my Community achievements bar.

SOLVED

club .csv and .txt files in to a single zip file

Avatar

Community Advisor

Hi Team,

 

We are generating 2 different files using data extraction activity.
Data extraction 1 will create test_1.csv
Data extraction 2 will create test_2.txt

 

We need to club this test_1.csv and test_2.txt file as a single zip file 'myProject.zip' and need to send to SFTP.

 

LakshmiPravallika_0-1659000425761.png

 

Kindly help us to achieve this!

Thanks

 

 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @LakshmiPravallika ,

 

Try using below script,
execCommand('zip -r -j /sftp/my/path/myProject.zip /sftp/my/path/test_1.csv /sftp/my/path/test_2.txt');

 

Regards,
ParthaSarathy S

View solution in original post

5 Replies

Avatar

Employee Advisor

Hi Lakshmi,

 

Please take a look at the documentation below and let us know if there are any questions. Do combine and zip both files into a single zip will likely take some scripting.

 

https://experienceleague.adobe.com/docs/campaign-classic/using/getting-started/importing-and-exporti...

 

Avatar

Community Advisor

Hi Thonis,

 

Thanks for providing me the link.But the documentation do not contain the steps to zip the files.

 

It only contain the steps to encrypt the files.

 

This doc doesn't help to achieve my use case of combining 2 files and zipping them into a single file.

Avatar

Correct answer by
Community Advisor

Hi @LakshmiPravallika ,

 

Try using below script,
execCommand('zip -r -j /sftp/my/path/myProject.zip /sftp/my/path/test_1.csv /sftp/my/path/test_2.txt');

 

Regards,
ParthaSarathy S

Avatar

Employee Advisor

Hi @ParthaSarathy  and @LakshmiPravallika 

Please restrain yourself to us execCommand when there is a JavaScript object to allow you to zip file.

Although the execCommand is there, we don't like it to be used as there is no control on what can be executed and it has been perceived as a security concern.

Please use ZipFile class instead and the getEntry

https://experienceleague.adobe.com/developer/campaign-api/api/m-ZipFile-ZipFile.html

ANYTIME, you use a File class, make you invoke the dispose function to release the resources used during the file processing, failing to do so exposes you to run out of resources and will require a full service restart.

execCommand works but is not recommended, ZipFile is the recommended approach.

Hope this helps,

Thanks

Denis