Rename *.csv to Daily_files.csv in SSIS 2008

  • Hi ,

    I am recieving flat files from FTP site whose file names are different but receiving from same location everyday. usi

    I would like to Rename *.csv files to Daily_files.csv in SSIS 2008.

    weekly files:

    1st day : Daily_files_03/01/2012.csv

    2nd day : Daily_files_03/02/2012.csv

    3rd day : Daily_files_03/05/2012.csv

    and so on....

    I tried file system task with rename option but it is not working.

    Please give me suggestions without using file system task and Execute Process Task.

    thanks,

    J

  • 1. Create code like below in Script Task: v_FileName is your source file.[C:\<Your File Name>.csv]

    Dim vFileName, vDate, vFilePath As String

    vFileName = CStr(Dts.Variables("v_FileName").Value)

    vDate = Now.Date.ToString("MM/dd/yyyy")

    vDate = Replace(vDate, "/", "")

    vFileName = Replace(vFileName, ".csv", "")

    vFilePath = vFileName & "_" & vDate & ".csv"

    Dts.Variables("v_TextFileName").Value = vFilePath

    Dts.TaskResult = Dts.Results.Success

    2. Using File System Task rename yoru file.

    Source is your variable: v_FileName

    Destination is your destination variable. v_DestinationFileName

    Create variables like below:

    v_FileName as string [C:\<Your File Name>.csv]

    v_DestinationFileName as string [C:\<Your File Name>.csv]

  • jasminipatel51181 (3/21/2012)


    I tried file system task with rename option but it is not working.

    Can you be a bit more specific? Are there errors or do you not get the desired results?

    Or do you go to the garage with your broken car and you say to the mechanic: "Car is broke. Plz fix."?

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • Thanks for the reply.

    my File name is not fixed it varies every day.

    Thanks,

    J

  • jasminipatel51181 (3/22/2012)


    Thanks for the reply.

    my File name is not fixed it varies every day.

    Thanks,

    J

    Well that clears things up.

    Personally, I'd keep the file name as-is and instead use a FOREACH loop to pick it up, passing the file name to a flat file datasource configured to pick up the file (via use of an expression).

    If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.

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

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