Paris Hilton


Hi,

Is it possible to use multiple masks in a For Each File Loop container

I need to process "*.txt" and "*.csv" and tried to separate them with all the usual characters("," ";" etc.) but it does not seem to work. I don't want to create 2 or more containers for each mask.

Thanks




Re: Multiple masks in a For Each File Loop container

scb2376


I don't usually respond to many posts, but when I saw that Paris Hilton was posting - I had to get in on the action.

Can you just go with *.* as your mask, then parse up the filename as the first step in the loop container, get the extension in a variable, and use file extension variable in your conditional flows to route the txt & csv to the relevant workflows, and then trash the files you're not interested in






Re: Multiple masks in a For Each File Loop container

Phil Brammer

I like that plan, scb2376.






Re: Multiple masks in a For Each File Loop container

Paris Hilton

Actually it's about cleaning up what I created in the TEMP folder, I don't want to wipe out everything there, only my "Mask1*.txt" and "Mask2*.csv". I was thinking of something similar when you use File->Open and you have multiple masks.





Re: Multiple masks in a For Each File Loop container

scb2376

I'm confused. If you only want to clean up certain files, then can you change your directory structure and have cleanup/scratch/trash stuff in one directory, while other files that you don't want to cleanup go in another Then you can wipe out everything in the folder. Or better yet, have different source folders for different file formats/extensions Not sure - maybe need some more context around what you're trying to do.

But your original question - I haven't noticed a multiple mask option.





Re: Multiple masks in a For Each File Loop container

Paris Hilton

Forget about the reason, too long to explain and doesn't solve anything, I could rewrite the package but would take too long; so let's go back to the original question: is it posible to use multiple masks in the For Each File Container

YES (how)

NO

Thanks





Re: Multiple masks in a For Each File Loop container

Phil Brammer

NO.

But you can do a *.* and then use precedence constraints to work with the *.txt and *.csv files.





Re: Multiple masks in a For Each File Loop container

scb2376

Ummm - I thought I did answer your original question.

scb2376 wrote:

But your original question - I haven't noticed a multiple mask option.

And I was just asking for clarification to help you. If you don't want to delete the other files, then do nothing with them, just let the loop continue.

Anyway - what I originally said (and then Phil later confirmed) will work fine. The below script parses up the filename and grabs the extension and puts it in a variable. Then in your precendence constraint editor, choose expression & constraint and make it something like (@sFileExtension=="txt")

Dim txtFileName As String

Dim intLength As Integer

Dim txtFileExtension As String

'Get Filename with path

txtFileName = Dts.Variables("sFileName").Value.ToString

'Get Length of path+filename

intLength = txtFileName.Length

'Get File Type/extension

txtFileExtension = txtFileName.Substring((intLength - 3), 3)

Dts.Variables("sFileExtension").Value = txtFileExtension





Re: Multiple masks in a For Each File Loop container

Phil Brammer

Just to expand a bit, you'd want in the precedence constraint:

@sFileExtension=="txt" || @sFileExtension=="csv"




Re: Multiple masks in a For Each File Loop container

scb2376

Ah - yes. In my head I was doing different things with the csv vs. txt, so I was sending them in two different directions.





Re: Multiple masks in a For Each File Loop container

Paris Hilton

Thanks guys,

It seems that I really want to stretch this tool (IS) and try to solve everything with as little code as possible, wasn't that the point of the tool I had to use scripts a couple of times when it was impossibe to solve the problem, but I have to run it by the "pros" before I do that.

Anyway, I guess the quickest solution is just to add 2 "For Each File Loops" with the 2 different masks and I'm fine. I did it already.