Copy Directories with SSIS

旧时模样 提交于 2019-12-13 04:54:48

问题


I am using SSIS with Visual Studio 2012.

I am using variables to make folders and folders within folders.

The parent folder is static VarFolderPath = c:\Source\test\

the first subdirectory within it is dynamic based on yyyymm. I use the following expression to make this folder stores in the variable VarFolderName.

@[User::VarFolderPath]+RIGHT("0" + (DT_STR, 4, 1252) DATEPART("yy" , GETDATE()), 4) +  (DT_STR, 2, 1252) DATEPART("mm" , GETDATE())

Within VarFolderName I then make four other folders CLI, Day3, INF, PRI. That is all working

I then want to copy CLI, INF, and PRI within the Day3 folder. I want two versions of CLI, INF and PRI. Oned irectly in VarFolderName, and another in Day3. I could make more variables to accomplish this, but since I already made the directories I was hoping to copy them. However using File System Task > Copy Directory does not copy folders, it copies all files within folders.

Thus other than adding three additional variables is there a way to leverage the directories I have already made (CLI,INF, PRI) and place copies of them in Day3 shown as numbers 5,6,7 below.

  • The end goal

    1. VarFolderName\CLI
    2. VarFolderName\INF
    3. VarFolderName\PRI
    4. VarFolderName\Day3

    5. VarFolderName\Day3\CLI

    6. VarFolderName\Day3\INF
    7. VarFolderName\Day3\PRI

回答1:


The file system task is pretty limited in SSIS - it is really intended for the most basic operations. Even with what you have so far, it is getting a bit complicated compared to what you could do in a script task. Please check out this code example and try rewriting this in c# or vb:

http://msdn.microsoft.com/en-us/library/bb762914(v=vs.110).aspx




回答2:


What about using xcopy via an Execute Process Task?

To do this, configure the task with Executable set to cmd.exe and Arguments equal to /C followed by the full command line you want to execute. For example, to copy the PRI directory to Day3\PRI, with destination directories created as needed, use /C xcopy /I /E PRI Day3\PRI.

If you'd like to use a single Execute Process Task to copy all three directories, try Arguments of \C xcopy /I /E CLI Day3\CLI & xcopy /I /E INF Day3\INF & xcopy /I /E PRI Day3\PRI.



来源:https://stackoverflow.com/questions/26598274/copy-directories-with-ssis

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!