OL Learn

Add a Compress or Zip plugin to Workflow

There are times when I need to compress/zip data files for extended backup purposes. Typically I use either 7Zip or xStandard xZip to perform the task. However various companies security department prevent or disallow using anything that is not part of the base install.

It would be nice if there was a compress/zip plugin that was distributed with the base install.

1 Like

In the meantime, here’s a WSC component ( Zipper.zip ) I wrote a while back that I use whenever I need to zip files.

To use it:

  • Unzip the WSC file in some known location (say, C:\Tests)
  • In a Workflow Script task, you can create a Zipper object by using the following syntax:
    var zip = GetObject("script:C:\\Tests\\Zipper.wsc");

Then you can do stuff like:
zip.open("C:\\Tests\\MyZip.zip",Watch);
zip.addFile(Watch.getJobFileName());
zip.extractFile("MyFile.pdf","C:\\Tests");
zip.addContents("<h1>Hello World!</h1>","MySnippet.html");
zip.close();

The WSC file contains a fair amount of comments, so you can read through them to get a better understanding of the available methods

Hello @Phil

I could use some help to make it work in a simple workflow to input files from sftp and unzip them:

The script I tried is:

var zip = GetObject("script:C:\\Secure Folder\\Local\\PPWorkflow\\Zipper.wsc");
zip.open("C:\\Secure Folder\\Portal\\OneDrive - PAPADOPOULOS\INTRUM\IN_KD\*.zip",Watch);
zip.extractFile("*.pdf","C:\\Secure Folder\\Portal\\OneDrive - PAPADOPOULOS\INTRUM\IN_KD\”);

The error I get is:

W3602 : Error 0 on line 3, column 96: Microsoft JScript compilation error: Unterminated string constant

Thank you
Akis

The last double-quote appears to be different.

"C:\\Secure Folder\\Portal\\OneDrive - PAPADOPOULOS\INTRUM\IN_KD\”<==

no, it was the same, but I noticed there were some double backslashes missing in the paths.
Now I get another error though:

W3602 : Error 0 on line 3, column 1: Microsoft JScript runtime error: 'oShell.NameSpace(...)' is null or not an object

What is the name of the Workflow’s Watch object I have to call in the open method?

It’s the same Watch object that is available in the scripting engine, and it’s aptly called Watch.

By the way, if all you want to do is extract files, you can simply use the Decompress task. The script in this thread was primarily provided as a way to compress files.

ok… din’t know about it.
Thank you @Phil!