Friday, March 6, 2015

How to zip and unzip / compress and uncompressed in SSIS using 7ZIP

The Execute Process Task will execute a Windows or console application inside of the Control Flow. You’ll find great uses for this task to run command-line-based programs and utilities prior to performing other ETL tasks. The most common example would have to be unzipping packed or encrypted data files with a command-line tool.


Famous example is zip and unzip the files. In this example, shows using 7Zip tool how to zip and unzip the files in SSIS.


Compress files or folders in SSIS

Executable: C:\Program Files\7-Zip\7z.exe
Arguments: a "C:\demo\doc.7z" "C:\demo\doc" (This can be construct dynamically using the variable and script task)


Uncompress files or folders in SSIS


Executable: C:\Program Files\7-Zip\7z.exe
Arguments: e "C:\demo\doc.7z"
Working Directory: C:\demo\doc

You can specify the password and other options

e @[User::FullPathtoZip] -o@[User::TargetFolder]-pPASSWORD -aOVERWRITE
Ex: e C:\demo\myfiles.zip -oC:\demo\extract\*.* -pXXXXXXXX -aoa

Overwrite options are
-aoa Overwrite all destination files.
-aos Skip over existing files without overwriting. Use this for files where the earliest version is most important.
-aou Avoid name collisions.

Please refer for further details
https://www.dotnetperls.com/7-zip-examples

Cheers!
Uma

1 comment: