1

I'm trying to zip a folder (C:\Temp\docs) using 7-zip in SSIS. I have added a Execute Process Task. Double click it. In Process tab, I add

Executable    C:\Program Files\7-Zip\7z.exe
Arguments     a -tzip

I would like the output zip file to be named doc_(current date).zip

Can someone please suggest how to add dynamic value to a variable name (in this case, the output zip file name)

Mike G
  • 4,232
  • 9
  • 40
  • 66
blue piranha
  • 3,706
  • 13
  • 57
  • 98

1 Answers1

3

Add an expression to your Execute Process Task (Right Click the task, click Properties, click on Expressions, click on the ellipses)

Choose Arguments for your Property, then for the expression, add something like the following:

"a -tzip doc_" + (DT_STR,4,1252)DATEPART( "yyyy" , getdate() ) +
RIGHT("0" + (DT_STR,4,1252)DATEPART( "mm" , getdate() ), 2) +
RIGHT("0" + (DT_STR,4,1252)DATEPART( "dd" , getdate() ), 2) +".zip"

This currently evaluates to the following:

a -tzip doc_20140129.zip

(Syntax taken from another SO answer).

I believe with command line 7zip you add your input file names (files to zip) as arguments, too. If so, just add them to the end of the expression.

Community
  • 1
  • 1
mr.Reband
  • 2,434
  • 2
  • 17
  • 22