Example in the below given link shows how you can loop through files of a given extension and load them into a database using Data Flow Task.
The example loads .csv files. The package uses a Foreach loop container
to loop through the files and there is a Data Flow task
within the loop container. The Data Flow task contains a Flat file source which changes based on the file being looped through. This is done by altering the Flat File Connection Manager path.
How do I move files to an archive folder after the files have been processed?
Here is an example that loops through a list of directories within a given directory and picks the most recently created folder using Script Task and Foreach loop container. You need to make use of a similar logic to pick the most recently created file.
How do I pick the most recently created folder using Foreach loop container in SSIS package?
Hope that helps.
Update:
Create two string data type variables namely DirPath
and FilePath
. Set the value C:\backup\ to the variable DirPath
. Do not set any value to the variable FilePath
.
Select the variable FilePath
and select F4 to view the properties. Set the EvaluateAsExpression
property to True and set the Expression property as @[User::DirPath] + "Source" + (DT_STR, 4, 1252) DATEPART("yy" , GETDATE()) + "-" + RIGHT("0" + (DT_STR, 2, 1252) DATEPART("mm" , GETDATE()), 2) + "-" + RIGHT("0" + (DT_STR, 2, 1252) DATEPART("dd" , GETDATE()), 2)