May 17, 2014 at 2:24 pm
I'd like to put an Execute Process Task inside a ForEach File container, so that if there is more than one .zip file in the Filedrop directory, it unzips each of them once and moves the files to the Fileprocess directory. I've got this working: The files are extracted and files moving to the destination directory, but then the foreach loop, loops again, triggering a DOS command window prompt informing me it's found a file already called Sales1 and asks if I want to overwrite the file with same name in destination directory or quit....
How can I get it to stop looping once it's processed all the zip files once?
These are the variables I've declared, all having Package scope:
ZipFolderPath = C:\StandardETLExample\Filedrop
ZipFileName = (no value)
UnzipFolderPath = C:\StandardETLExample\Fileprocess
ExecuteablePath = C:\Program Files (x86)\7-Zip\7z.exe
The configuration of the ForEach Loop Container is as follows:
(1) Collection-> I've set property to Directory and Expression to @User:ZipFolderPath, Name & Extension selected for Retrieve File Name
(2) Variable Mappings -> variable to ZipFileName with value of 0
(3) In properties I've set DelayValidation to True.
The configuration of the Execute Process Task is as follows:
(1) Process -> Executable: is dynamically generated and resolves as follows: C:\Program Files (x86)\7-Zip\7z.exe
->Arguments: is dynamically generated and resolves as follows: x -oC:\StandardETLExample\Fileprocess
(2) Expressions
-> the expression for the executable is @[User::ExecuteablePath]
-> the expression for the Argument is "x "+ @[User::ZipFolderPath] +" -o" + @[User::UnzipFolderPath]
The error I get is
[Execute Process Task] Error: In Executing "C:\Program Files (x86)\7-Zip\7z.exe" "x C:\StandardETLExample\Filedrop -oC:\StandardETLExample\Fileprocess" at "", The process exit code was "-1073741510" while the expected was "0".
but infact at this point the package has done what it's supposed to do and should exit.
How to stop the loop?
May 17, 2014 at 9:19 pm
Simple solution, use the ForEach File to move the files to an "unzip" directory and unzip from there to the Fileprocess directory.
😎
May 17, 2014 at 10:34 pm
So, are you saying that I need to first move the zip file to a second folder to isolate it, before unzipping and moving it's contents to a third folder? Doesn't that mean I'll also have to delete the zip file in the second folder before I move another zip into it from the first folder?
May 18, 2014 at 12:49 am
KoldCoffee (5/17/2014)
So, are you saying that I need to first move the zip file to a second folder to isolate it, before unzipping and moving it's contents to a third folder? Doesn't that mean I'll also have to delete the zip file in the second folder before I move another zip into it from the first folder?
Normally one moves the file to an archive directory after unzipping and before processing the next file. It is not necessary to delete it from the unzip folder (unless it has the same name) as you are not iterating through that folder but processing by file name.
😎
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply