Hi,
Using the 'for each' container, I am setting a user variable (type = string) which will hold the source file name and path of files to process and then move to an archive directory.
In the move file task (which is in the for each loop container) I have set the destination to a file connection, and the source to : Issourcepathvariable=True; sourcevariable=user::sourcefilename
BUT
when I run the package, I get the following error : Error at File System Task : "Source Path" is not valid on operation type "move file".
I have tried all sorts of things relating to expressions etc. but cannot get this to work. I am obviousley doing something fundementally wrong...can anyone help me?
Thanks
Kevin
Kevin,
It looks like you may have a problem in the user::sourcefilename variable. If I were you I would put a breakpoint on the file system task and, when it breaks at debug-time, put a watch on user::sourcefilename. See what teh value in there actually is.
-Jamie
|||
thanks Jamie.
I have removed the file system file task from the container, and run the package with a breakpoint on the begining of every iteration of the loop. By looking at the watch window, I can see that the variable is being set correctly with the first filename in the filesystem folder.
When I add the filemove task however and add the variable as the source, the package seems to want to validate the variables contents before it has been set by the container, and I am therefore getting an error message.
Does this make sense?
Cheers, Kevin
|||
Kevin,
did you try to enter a "default" or "dummy" filename for that? I remember that I had some problems in a similar case...
|||kevin w wrote:
thanks Jamie.
I have removed the file system file task from the container, and run the package with a breakpoint on the begining of every iteration of the loop. By looking at the watch window, I can see that the variable is being set correctly with the first filename in the filesystem folder.
When I add the filemove task however and add the variable as the source, the package seems to want to validate the variables contents before it has been set by the container, and I am therefore getting an error message.
Does this make sense?
Cheers, Kevin
Kevin,
Yes, that makes perfect sense. Set DelayValidation=TRUE on your File System Task. I *think* that will solve the problem.
-Jamie
|||
Cheers Jamie,
It's always the little things the trip me up!!!!
Your solution worked a treat.
Kevin
|||Kevin and Jamie
I am trying to move a file from a folder to an archive folder. I do not know how to create an expression. The file name will change everyday. It is a txt file. How can I specify to move a file *.txt from a folder to archive folder. Any help will be greatly appreciated.
Thanks
Annie
|||AYK wrote:
Kevin and Jamie
I am trying to move a file from a folder to an archive folder. I do not know how to create an expression. The file name will change everyday. It is a txt file. How can I specify to move a file *.txt from a folder to archive folder. Any help will be greatly appreciated.
Thanks
Annie
Annie,
Are you trying to move all files which match the pattern "*.txt"? If so, look into using the MULTIFILE connection manager.
Here in BOL: ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/extran9/html/10bdc56e-c5cd-4ddb-b2f7-375fe57fe8b2.htm
-Jamie
|||Jamie
Yes I am trying to move all files with *.txt into an archive folder. I understand the use of multifile connection manager but I am not sure how I can associate the connection manager to a File System task to move file. In the file system task, for the source it asks for a single file name and does not allow me to specify the multifile connection manager
Thanks
Annie
|||Ah yeah, you're right. Sorry about that.
In this case then you will need to use a ForEach loop with the FileEnumerator. Loop over all the *.txt files and move them one by one to your destination.
-Jamie