Showing posts with label SSIS zip a file. Show all posts
Showing posts with label SSIS zip a file. Show all posts

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

Tuesday, December 13, 2011

SSIS: How to Compress/Zip your file using 7-Zip?

This post shows how you can zip your file using SSIS .

As per the need sometime you might need to zip your files in order to save some space or you might want to create a zip file and set a password on it before sending to some one.

File compression is a very interesting topic. There are many tools available to compress/zip your file such as Winzip, 7-Zip, ezyZip, WindowsRar and many more. We can use any one to compress/zip our file. I have used 7-Zip to compress/zip my file for this post.

I have following file in my local drive.

The file name is RupeeStory.txt and file size is 474 KB. I want to Compress/zip this file. I know the file size is not large but this is purely for demonstration purpose.

In SSIS, I have created a SSIS package and on Control Flow tab I have added an Execute Process Task task

I have setup the Process tab of Execute Process Task Editor as following. My file name is RupeeStory.txt and my zip file name is ZipMyFile.7z

After setting this I run my SSIS package and it runs successfully and created a zip file in my local drive.

Simple!!

Now I want to create a zip file and set the password on it. I edited the Arguments as following

a "C:\ZipMyFile.7z" "C:\RupeeStory.txt" -pabc@2011

Where abc@2011 is the password. So anyone extracting my zip file need to know the password

You can use the other settings as well like adding your file to an archive, deleting a file from archive, extract files from archive etc. The only thing is you should be familiar with the command-prompt switches or Start-up switches of your favorite zipping tool. In case you use 7-Zip here is an screen shot of all the start-up switches you can use.

I hope you like this article.

Related Article:

Popular Posts

Real Time Web Analytics