Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Wild Card Character in For Each loop container of SSIS package Expand / Collapse
Author
Message
Posted Monday, July 19, 2010 8:57 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Tuesday, July 8, 2014 10:54 AM
Points: 78, Visits: 280
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.
Post #954867
Posted Monday, July 19, 2010 9:39 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Tuesday, January 3, 2012 11:53 AM
Points: 231, 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.
Post #954900
Posted Wednesday, July 21, 2010 2:46 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Wednesday, July 21, 2010 3:45 AM
Points: 4, 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"
Post #956174
Posted Wednesday, July 21, 2010 7:05 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Tuesday, July 8, 2014 10:54 AM
Points: 78, Visits: 280
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.
Post #956321
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse