Search File with Widecard

  • I need some help in coding for a script task for a SSIS package.

    I have a folder called TestFile in D:\, and I am placing a text file with the name starting with E, and want to rename it as testfileYYYMMDD.txt.

    So, here is what I try to write for the script task:

    Public Sub Main()

    Dim sSourceFile As String

    Dim sDestinationFile As String

    sSourceFile =

    sDestinationFile = "d\test\"testfile" + Date.Now.ToString("yyyyMMdd") + ".txt"

    'System.IO.File.Move(sSourceFile, sDestinationFile)

    System.IO.File.Move(sSourceFileA, sDestinationFileA)

    Dts.TaskResult = Dts.Results.Success

    End Sub

    End Class

  • Why are you using script task to do this? Doesn't a file system task meet your needs?

  • QQ-485619 (7/21/2014)


    I need some help in coding for a script task for a SSIS package.

    I have a folder called TestFile in D:\, and I am placing a text file with the name starting with E, and want to rename it as testfileYYYMMDD.txt.

    So, here is what I try to write for the script task:

    Public Sub Main()

    Dim sSourceFile As String

    Dim sDestinationFile As String

    sSourceFile =

    sDestinationFile = "\\co-2K3fsa03\DATA2\MCO\ELDERPLAN\Interfaces\EOP\ToEmdeom\" + Date.Now.ToString("yyyyMMdd") + "HZBER8F22ABF" + ".txt"

    'System.IO.File.Move(sSourceFile, sDestinationFile)

    System.IO.File.Move(sSourceFileA, sDestinationFileA)

    Dts.TaskResult = Dts.Results.Success

    End Sub

    End Class

    So, why are you doing a MOVE? Why not just use a good ol' fashioned DOS RENAME command?

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • To answer the rest of your question (how to get the source file) from this thread, http://www.sqlservercentral.com/Forums/Topic1594694-391-1.aspx that I commented was a duplicate.

    I'd use the For Each Loop Container which allows you to loop over files in a directory and then use the File System Task within the loop to process/rename/move the file.

Viewing 4 posts - 1 through 3 (of 3 total)

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