如何将多个目录中的最新文件复制到公共目录中?

如何将多个目录中的最新文件复制到公共目录中?

问题描述:

我想 使用ssis包将新创建的文件(.orig)从多个目录复制到公共文件夹中。

I want to  copy newly created file(.orig) from multiple directory into common folder using ssis package .

Diretory包含文件名的形式为PSANsiteIDfromtodate_filecreateddate每个站点每周都会收到此文件。

Diretory contains file name is in form of PSANsiteIDfromtodate_filecreateddate this file is recevied weekly for each site .

文件启动PSANsite仍然是常见的,只有更改日期。

file starting PSANsite remains common only date get changed.

我尝试使用cmd 

I have tried to this using cmd 

进行/ R" source"  %f in(* .orig)do copy%f  "目的地"

for /R "source" %f in (*.orig) do copy %f  "destination"

使用此命令我能够从多个文件夹中检索文件但无法获取新文件从目录中创建文件

请指导我解决此问题




您好,  

Hello, 

您可以创建一个批处理文件并从SSIS调用它,批处理文件中的内容将是这样的:

You can create a batch file and call it from SSIS, the content in the batch file would be something like this:

for /f %%i in ('DIR /B /O:D /S "C:\SourceFolder\*.orig"') DO SET newestFile=%%i 
copy "%newestFile%" "C:\TargetFolder"

相关链接:

SSIS - 如何使用SSIS执行批处理文件套餐

SSIS - How To Execute Batch File By Using SSIS Package