Wild Card Character in For Each loop container of SSIS package

  • Hi,

    I am developing a package which will look for the particular type of file pattern and creates the folder and copies those files to that folder.

    Here is my requirement:

    Look for files like "dtcabc20100719.txt" and "dtcxyz20100719.txt" and create a folder Client20100709 then copy both the files to this folder.

    I am trying to use for each loop container to loop thru files which has file specification as

    dtc___yyyymmdd.txt

    I tried with _ to match the single character but it didn't worked. because it is considering it as

    dtc___2010719.txt

    I tried with wild card character * which will process all the files dtc*. but I want to combine all the files with the current date in the folder.

    Is there any specific wild card character available which represents the single character in for each loop container?

    Thanks.

    Gunjan.

  • Gunjan check this out

    http://www.sqlservercentral.com/articles/SSIS/68025/

    You can use the script to get dynamic filename and use that in forloop... not exactly you are looking for but this can do the trick.

  • Hi,

    Can you try the following steps

    1. Use Execute process task to call a batch file (This batch file will create the folder and copy the files to that folder you can have the batch commands as shown below)

    @echo off

    cls

    mkdir C:\Client%

    copy "C:\abcdef\testfiles\dtc*.txt C:\Client%

    Note: % represents the parameter, you can provide this parameter as date dynamically in Execute process task expressions.

    2. Use For each loop container and enumerator as for each file enumerator and point it the folder where we stored our files which we have to rename

    3. Create a new variable (variable name for example v_FileName) to store the file names in it and map it in variable mapping tab

    4. User File system task inside for each loop container and use operation as rename

    5. The file connection manager which we are using in file system should be dynamic (Use connection string expression to make it dynamic, here we

    have to use the variable which we mapped in for each loop container (v_FileName))

    Expression which we will use for connection string expression will looks like this

    Example : "C:\\Client21072010\\"+ @User::v_FileName + (DT_STR, 10, 1252) ((DT_DATE) GETDATE()) + ".txt"

  • Hey seshu.vnkt

    Thanks for the reply.

    I think u didn't get my requirement. In my file name i have first couple of characters same next set is different and last set has date (which will be the current date).

    So I want to have "dtc___<<current Date>>.txt"

    the blank line is of 3 characters which could be any but the first and last set will be same.

    Thanks.

    Gunjan.

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

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