Click here to Skip to main content
15,916,941 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,


I have one source directory with 10 text files, two source directories like namely Destination1, Destination2.
10 text files names:
1)Feed1
2)other7
3)Feed3
4)Feed4
5)Feed5
6)Feed6
7)Feed2
8)other8
9)other9
10)other10

now i want move files(with name Feed*.txt) to Destination1 directory, and move rest of files to Destination2 directory.How to achieve in SSIS???
Posted

Use a File System Task. But since you are going to two different destinations you may need two File System Tasks. I believe you can only move one file at a time however.

So you may need a ForEach Loop Container.

See here: http://www.sqlservercentral.com/Forums/Topic508448-148-2.aspx#bm752592[^]
 
Share this answer
 
use foreach loop tool for enumerate each file, Use a File System Task inside the loop followed by script task. configure file system task with destination variable, this destination variable should come from script task. script task code as below:
"
using System;
using System.Data;
using Microsoft.SqlServer.Dts.Runtime;
using System.Windows.Forms;
using System.IO;
namespace ST_61a0f7e8968e4c2ba69c3e2dc24d3366.csproj
{
[System.AddIn.AddIn("ScriptMain", Version = "1.0", Publisher = "", Description = "")]
public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
{

#region VSTA generated code
enum ScriptResults
{
Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success,
Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
};
#endregion

public void Main()
{
String feedname = Dts.Variables["SourceFeed"].Value.ToString();
String DestPath = Dts.Variables["DestinationPath"].Value.ToString();
String desiredfilanameformat= (Dts.Variables["myformat"].Value.ToString()).ToUpper();
String FileName = Path.GetFileName(feedname);
FileName = (FileName.Substring(0, desiredfilanameformat.Length)).ToUpper();
// System.Windows.Forms.MessageBox.Show(FileName);
if (FileName.Equals(desiredfilanameformat))
{
Dts.Variables["DestinationPath"].Value = "C:\\destinationfolder";
}
else
{
// System.Windows.Forms.MessageBox.Show("Filename:" + FileName + " desiredfilanameformat" + Customername);
Dts.Variables["DestinationPath"].Value = "C:\\destinationfolder2";
}
Dts.TaskResult = (int)ScriptResults.Success;
}
}
}"
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900