Integration Services - copy folder

  • Hi,

    I have a folder with 10 text files. I want to copy the folder to a new location, create a new folder with the date appended to the end. The next day I want to do the same task, copy the folder from the same source location to a new folder with the name appended to the end. I can do the folder copy task fine, however not sure how to get SSIS to create a new folder with a new name each day.

    Any help would be appreciated

    Cheers.

  • You can do it with a Visual Basic Script task. Here's an example of some code to get you started. It creates a new folder based on the current date.

    Public Sub Main()

    ' Set the task results to Success before calling the sub routines.

    ' The value is set to Fail if one of the sub routines fails.

    Dts.TaskResult = ScriptResults.Success

    Try

    Dim sNewFolder As String

    sNewFolder = "\\Reports\" & DateAdd(DateInterval.Day, -1, Date.Now).ToString("yyyy") & "_" & DateAdd(DateInterval.Day, -1, Date.Now).ToString("MMdd")

    If Dir(sNewFolder) = "" Then

    My.Computer.FileSystem.CreateDirectory(sNewFolder)

    End If

    End Sub

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply