Sunday, June 9, 2013

SSIS: How to extract/unzip files to a folder using 7-Zip?

This post will show how we can extract contents of a zip file using 7-zip with SSIS.

7-zip is a good tool to zip, compress and extract files and folders. In case you have a requirement to compress/zip the files or extract a zip files received by a customer, you can do this easily with SSIS.

I have previously posted an article on How to zip/compress you files using 7-zip, in this post we will explore how we can do the vice versa that is how to unzip a files.

The steps in SSIS are simple to follow. Let us say we have a zip file called xyz.zip that is located in our hard disk. To unzip this with SSIS we have to create a package. In the package let us add Execute Process Task.

In the Execute Process Task set the Executable property to the C:\Program Files\7-zip\7-zip.exe or whatever location your 7z.exe is installed.

In the Arguments you can write x [Zip File Location] -o[Destinatin Folder Location]. For example if your zip file is in D drive and you want to extract the contents of this zip file to temp folder you can write argument like D:\xyz.zip -oD:\temp.

That is all you need to do. You can add your own creativity to make it more dynamic but I hope the concept is clear.

Keep this in mind, if the files already exists in the destination folder, a command line window will pop-up during package execution to confirm about the overwrite of files.

To Know more about the arguments of 7-zip that you can use with SSIS, you can follow this excellent page at dotnetperls.com

Popular Posts

Real Time Web Analytics