Thursday, 26 October 2017

Zip and unzip the files using 7-Zip in SSIS

ZIP is an archive file format that supports lossless data compression. A .ZIP file may contain one or more files or directories that may have been compressed.
We have many scenarios that we need to zip many files which we come across and then so some operations like either sending it as an email or just moving the zipped file to some other destinations etc.
 zipping or unzipping manual is a very tedious task. Here we will learn how to zip and unzip files in SSIS.

Let’s see how to zip or unzip the file using 7-Zip in SSIS

Open the SSDT.
Take Execute process task.
  
Before configuring the execute process task see the files which we are going to zip
First, we will zip one file after that we will learn to zip all files in folder
  

Here I am going to Zip Emp.txt file.
Now I am configuring the Execute process task.
  

There below properties, we need to configure
Ø  Executable
Ø  Arguments
Ø  Working Directory

Executable:

Here we need to set the exe path of 7-Zip



Select the 7z Executable exe.
Click ok.

Arguments

In Arguments, we need to give the zip command and zip file name and file name
a -t7z "F:\Emp.ZIP" "F:\Emp.txt"
a –t7z is used for zipping.

Working Directory

Where we want to zip the files
F:\


Now click ok.
Now the package is ready to run.


Before running the package.


Now I am running this package.


The package is completed successfully. See the output.


Zipped the file.


Zip all files from a folder

For zipping the files from a folder we need to change argument
  
If we give *.* then it will take files. If we to archive some specific file format then we need to give *.File extension (e.g. *.txt, *.cvs etc)
Click ok.
Package is ready to run
Before running the package.
  
Now I am running this package.

See the output

See the zip files

Unzip the files

To unzip the file, we need to change the argument.

I want to extract files on UnZip folder.
Now I am executing the package.
See the output

 

Popular Posts