club .csv and .txt files in to a single zip file | Community
Skip to main content
LakshmiPravallika
Community Advisor
Community Advisor
July 28, 2022
Solved

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

  • July 28, 2022
  • 3 replies
  • 2061 views

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.

 

 

Kindly help us to achieve this!

Thanks

 

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by ParthaSarathy

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

3 replies

Craig_Thonis
Adobe Employee
Adobe Employee
July 28, 2022

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-exporting-data/managing-data-encryption-compression/zip-encrypt.html?lang=en

 

LakshmiPravallika
Community Advisor
Community Advisor
July 28, 2022

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.

ParthaSarathy
Community Advisor
ParthaSarathyCommunity AdvisorAccepted solution
Community Advisor
August 4, 2022

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

~  ParthaSarathy S~  Click here to join ADOBE CAMPAIGN USER GROUP for Quarterly In-person | Hybrid | Virtual Meetups
Adobe Employee
August 4, 2022

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