Moving zip files

  • Hi guys

    This sounds like it should be simple but I'm banging my head on the brick wall again.
    I have an SSIS process that extracts the contents of a zip file in a specific folder then processes it.

    The contents of the zip are the same, the source folder never changes BUT the zip file name can be anything.

    I'd like SSIS to move the source file to a specific folder (processed files) after the unzip is done. The Unzip works fine with a variable (*.zip) in the argument. My project uses variables to rename files from data they contain later on, but this time I want to leave the name the same, just move it. The standard file move uses a fixed name, and I can't seem to get a variable name to work. The flat file connection seems to barf on a zip file when I try it.
    I don't need to do a for each loop, just a single move on a single file.

    I'd be happy if anyone could point me in the right direction.
    Thanks
    Steve

  • Are there multiple files in the source? I'm not much of an SSIS guy, but the pattern I've seen is use a loop to process all files in a folder, move, load, ignore, whatever. Then as you process each file, you have the name of that file inside the package and can access that. Usually people loop through the files, do something, then move. You're the opposite in that you loop, move, then load. I'd think you really are looping, move, then another loop (perhaps another package) that processes the folder in which you've moved files.

    If you process the folder and enumerate each file, the file task inside your loop should be able to access each name and load that.

  • Steve has got it right, despite his 'not much of an SSIS guy' disclaimer 🙂

    Use a FOREACH loop to process the file, even though you know that there will be only one zip file present. Why? Because the FEL does the work of mapping the exact file name to a variable of your choosing (which also means that you can make your unzip command more refined).

    If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.

  • Phil Parkin - Tuesday, February 6, 2018 5:50 AM

    Steve has got it right, despite his 'not much of an SSIS guy' disclaimer 🙂

    Use a FOREACH loop to process the file, even though you know that there will be only one zip file present. Why? Because the FEL does the work of mapping the exact file name to a variable of your choosing (which also means that you can make your unzip command more refined).

    Seconded. Very easy to setup and lots of guides online how to do this with any file extension. Matter of fact, I don't think I've ever not used one even when I know it's just one file. Just in case it becomes more than one, I don't have to go back to it.

    Outside of that, I've actually used script tasks for unzipping with Python. Seemed easier to do those types of operations in another scripting language like Python or so that would unzip, rename, and so forth.

  • xsevensinzx - Tuesday, February 6, 2018 6:16 AM

    Outside of that, I've actually used script tasks for unzipping with Python. Seemed easier to do those types of operations in another scripting language like Python or so that would unzip, rename, and so forth.

    Me too ... in C#.

    If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.

  • Sounds like someone should write me an article on this.

  • Thanks guys. So many responses and all pointing me the same way!

    My decision that I didn't need a loop was based on the single file process, but I guess the loop through a single file won't add much other than complication, and what I was trying was complicated and didn't even work!
    A for-each loop with variables I can handle!
    Thanks again guys.

  • steve.alston - Tuesday, February 6, 2018 2:34 PM

    Thanks guys. So many responses and all pointing me the same way!

    My decision that I didn't need a loop was based on the single file process, but I guess the loop through a single file won't add much other than complication, and what I was trying was complicated and didn't even work!
    A for-each loop with variables I can handle!
    Thanks again guys.

    It's really not. I'm no SSIS expert either, but I remember reading one good article on how to loop through excel files one time and pretty much do it for every file I import, single or not. It's very easy to the point you should be able to do it by memory every time you make one.

    I would only note here, that you should also consider file validation with your processing. Don't just import any file in a directory. Validate it first, then start your process.

Viewing 9 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic. Login to reply