Zipping the .Txt Files



Hi Team,

I am trying to zip a .txt file using below code:

var w = vars.filename;              //file path + file name: + ".zip", true);         this is where the zipped file will be saved. You must include the zipped file name including .zip file extension

Above code is working fine on our dev instance where source and target are locally hosted . but the same code is giving issue on UAT instance as source and target are remotely hosted.

Then we used the below code on UAT instance , that is able to generate zip file but multiple folder are getting created under zip file.

execCommand("zip '" + w + "'.zip '" + w + "'");  (in place of + ".zip", true);)

So anyone can help me with some another set of code or any suggestion on this.



Accepted Solutions (0)

Answers (2)

Answers (2)



Thanks buddy for the response.

But I have tried all the possible combinations with w and y variables.

var w = vars.filename;

execCommand("zip '" + w + "'.zip '" + "/" + y + "'");

execCommand("zip '" + w + "'.zip '" + "/" + w + "'");

execCommand("zip '" + y + "'.zip '" + "/" + w + "'");

execCommand("zip '" + y + "'.zip '" + "/" + y + "'");

In the above command "y" represent the the filename only)

We checked the folder where we are trying to place the zip file but its not there.

var w = vars.filename;              //file path + file name: /usr/local/neolane/outgoing/TEST_ABCI_00000100_20171025193028.txt

var x = w.split("/");

var y = x[5];                       //fileName: TEST_ABCI_00000100_20171025193028.txt

So it would be helpful if we can have some another set of code for zipping the files or updates in this command.Amit KumarAdhiyan​, Could you guys please have a look over my issue and help me out.



var w = vars.filename;

In case of execCommand, if the filename contains the absolute path (i.e. /home/somefolder/file.txt) then same folder hierarchy will be created inside zip file. Modify the w variable to get only file name.