ktbsandeep
asked on
I need to unzip all files in a folder using SSIS.
I need to unzip all files in a folder using SSIS. Right now I am able to unzip individual files by hardcoding their names. I want all to be done at once.
You could call a program like 7-zip (7za.exe needs no installation) from the a script control in SSIS.
This will show you how to loop files in a folder.
http://blogs.conchango.com/jamiethomson/archive/2005/05/30/SSIS_3A00_-Enumerating-files-in-a-Foreach-loop.aspx
http://blogs.conchango.com/jamiethomson/archive/2005/05/30/SSIS_3A00_-Enumerating-files-in-a-Foreach-loop.aspx
ASKER
When I am trying to use a execute process task and providing the winzip32.exe in executables. I am facing problems in sending all zip file names as argument to that. Please let me know how to send the file names as an argument in execute process task.
If you use 7-zip you can execute it in a shell from a VB.NET script control
ASKER
Thanks. Can you please send me 1 example on how to use 7-zip and execute it in a shell from a VB.NET script control.
I;ve edited some old vbScript I have but a function to zip a file should look something like this:
Private Sub ZipFile(ByVal sFromPath As String, ByVal sToPath As String, ByVal sFromFileName As String, ByVal sToFileName As String)
Dim s7za As String = "C:\Program Files\7-Zip\7za.exe"
Dim sArguments As String
Dim myProcess As New System.Diagnostics.Process
Dim sFullFromFileName As String
Dim sFullZipFileName As String
sFullFromFileName = sFromPath & sFromFileName
sFullZipFileName = sToPath & sToFileName
sArguments = " a -tzip -mx1 -y """ & sFullZipFileName & """ """ & sFullFromFileName & """"
myProcess.Start(s7za, sArguments)
End Sub
Private Sub ZipFile(ByVal sFromPath As String, ByVal sToPath As String, ByVal sFromFileName As String, ByVal sToFileName As String)
Dim s7za As String = "C:\Program Files\7-Zip\7za.exe"
Dim sArguments As String
Dim myProcess As New System.Diagnostics.Process
Dim sFullFromFileName As String
Dim sFullZipFileName As String
sFullFromFileName = sFromPath & sFromFileName
sFullZipFileName = sToPath & sToFileName
sArguments = " a -tzip -mx1 -y """ & sFullZipFileName & """ """ & sFullFromFileName & """"
myProcess.Start(s7za, sArguments)
End Sub
ASKER
This script is agin to zip a single file. I am in need of unzipping all files in a folder.
You could call it once for each file in the folder and it will add each file to the zip
ASKER
How can I do that using the "Execute Process Task" in SSIS. Can you please explain me that?
You can do it from a script control. You can just write .NET code in a scriipt control so can erxecute things using System.Diagnostics.Process .
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.