File System Task : create folders and files dynamically ?
Hi, While exporting the data , i need to send it to Excel file. While doing so i want to Create a specific folder and then save the excel file in that particular folder with the date. Eg: C:\ I want to Create a Folder in C named (Inbox) and in that store my excel file ie : Excel_TodaysDate. Can i do all this things when the package executes. Can anyone help guide me how to create a folder and then create a file(with current date) in that folder. Thanks & Regards, Bhavika
April 18th, 2011 2:15am

Yes, a folder or directory can be created using the File System task and the excel file with date can be created by using expressions in the excel connection manager or using a script task the fexcel file connection manager can be set dynamically with the date appended.Request to please mark my post as an answer if I helped you to resolve the issue or vote up if I helped you.Thanks. Regards and good Wishes, Deepak.
Free Windows Admin Tool Kit Click here and download it now
April 18th, 2011 2:18am

you can do this with File System Task with operation as Create Directory. or use Script Task and use System.IO.Directory.Create method to create folder.http://www.rad.pasfu.com
April 18th, 2011 2:19am

Ok so if i have to Create a Folder first and then add a file , so i need to use 2 file system task.Thanks & Regards, Bhavika
Free Windows Admin Tool Kit Click here and download it now
April 18th, 2011 4:47am

Ok so if i have to Create a Folder first and then add a file , so i need to use 2 file system task. Thanks & Regards, Bhavika yes, or you can use SCRIPT Task way, and do create folder and add file in single script task.http://www.rad.pasfu.com
April 18th, 2011 4:49am

Thanks Reza. 1) I have a source table. 2) I am using File System Task to create folder 3) I am Using Data Flow Task -> to Send data from Table(DB) to Excel File 4) Again i use a File System Task to move my this excel to that particular folder . Is my approach correct or i can do it in a simpler manner. I think i am going somw where wrong , i guess in 3 and 4 point . Please guide. And i want to create my file dynamically . with say todays date , so then my approach is wrong for that . Thanks & Regards, Bhavika
Free Windows Admin Tool Kit Click here and download it now
April 18th, 2011 5:11am

It is better to have a sample empty excel file first, sample excel file with column headers but no data. then design this schema: 1) First file system task to create folder 2) second file system task to copy sample empty excel file to created folder 3) do Data flow with destination to the file which is already exists in the target created folder. http://www.rad.pasfu.com
April 18th, 2011 5:17am

Ya m doing that . It working. 1 issue is i am trying to rename the file but not able to get the expression correct . Can you plz help. I reffered this post : http://beyondrelational.com/blogs/niteshrai/archive/2010/04/05/creating-a-file-using-ssis-file-system-task.aspx but the Replace expression that is there is not working , its gives a error "[File System Task] Error: An error occurred with the following error message: "Illegal characters in path.". Can you please help me correct the expression . Thanks & Regards, Bhavika
Free Windows Admin Tool Kit Click here and download it now
April 18th, 2011 6:20am

what is your expression exactly? http://www.rad.pasfu.com
April 18th, 2011 6:25am

I need to Replace the File name : expression is : "C:\\XYZ\\" +REPLACE(SUBSTRING( (DT_WSTR,30)GETDATE(),1,10),"-","")+ ".xls" i am using the same expression to Replace my File NameThanks & Regards, Bhavika
Free Windows Admin Tool Kit Click here and download it now
April 18th, 2011 6:39am

this expression will generate a filename based on current date, result will be like this: C:\XYZ\20110418.xls if you have a file name and you want to rename it you should fetch it from your source file path, this means that you should use your directory path instead of C:\XYZ in this expression. if all of these doesn't make sense to you , let me know what is your file path exactly? and what is your desired file name after rename? http://www.rad.pasfu.com
April 18th, 2011 6:48am

ya thats wat i want. I want to name my File with say : Material_20110418.XLS ... can you give me the expression ?? The above expression i used just for date was throwing an error as i had mentioned earlier.Thanks & Regards, Bhavika
Free Windows Admin Tool Kit Click here and download it now
April 18th, 2011 7:45am

Hey can any one plz give me a expression to Replace / Rename file name. I want my file name to be eg: Material_TodaysDate ie Materials_20110418.XLS please help me with this expresion. I am using File system task to Replace/Rename the file . Thanks & Regards, Bhavika
April 18th, 2011 8:09am

The filename or the excel file path has to be modified before it gets assigned to the File System task. For this , the excel file path has to be extracted and modified to get appended with the date and place it in the destination in a script task. I was able to achieve this wihout the use of file system task for the rename. Script will assign the new connection string to the destination excel while the data flow task places the data in the excel for the renamed file in the location configured in the script task.Please mark my post as an answer if I helped you to resolve the issue or vote up if I helped you.Thanks. Regards and good Wishes, Deepak.
Free Windows Admin Tool Kit Click here and download it now
April 18th, 2011 9:42am

ya thats wat i want. I want to name my File with say : Material_20110418.XLS ... can you give me the expression ?? The above expression i used just for date was throwing an error as i had mentioned earlier. Thanks & Regards, Bhavika you can use this expression: "C:\\XYZ\\Material_" +REPLACE(SUBSTRING( (DT_WSTR,30)GETDATE(),1,10),"-","")+ ".xls" http://www.rad.pasfu.com
April 18th, 2011 11:14am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics