Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Wild Card Character in For Each loop container of SSIS package


Wild Card Character in For Each loop container of SSIS package

Author
Message
Gunjan
Gunjan
SSC Journeyman
SSC Journeyman (82 reputation)SSC Journeyman (82 reputation)SSC Journeyman (82 reputation)SSC Journeyman (82 reputation)SSC Journeyman (82 reputation)SSC Journeyman (82 reputation)SSC Journeyman (82 reputation)SSC Journeyman (82 reputation)

Group: General Forum Members
Points: 82 Visits: 309
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.
Ghanta
Ghanta
SSC Veteran
SSC Veteran (233 reputation)SSC Veteran (233 reputation)SSC Veteran (233 reputation)SSC Veteran (233 reputation)SSC Veteran (233 reputation)SSC Veteran (233 reputation)SSC Veteran (233 reputation)SSC Veteran (233 reputation)

Group: General Forum Members
Points: 233 Visits: 698
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.
seshu.vnkt
seshu.vnkt
Forum Newbie
Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)

Group: General Forum Members
Points: 6 Visits: 16
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"
Gunjan
Gunjan
SSC Journeyman
SSC Journeyman (82 reputation)SSC Journeyman (82 reputation)SSC Journeyman (82 reputation)SSC Journeyman (82 reputation)SSC Journeyman (82 reputation)SSC Journeyman (82 reputation)SSC Journeyman (82 reputation)SSC Journeyman (82 reputation)

Group: General Forum Members
Points: 82 Visits: 309
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.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search