August 19, 2009 at 3:06 am
Hi All,
I am creating a SSIS package which copies files from one location to another.
Problem
There are over 5000 files in the source folder and i am only looking for PDF's which include no _ (underscore).
i.e. xxxxxxxx.pdf NOT xxxxx_xxxxx_xxxxx.pdf
What would the exspresion look like?
Thanks
August 19, 2009 at 1:50 pm
There are a bunch of different ways you could handle this.
Are you using a Foreach Loop Container and using "*.pdf" in the Files text box under the Enumerator Configuration of the container's editor? Are you storing the file name and/or path in a package variable?
Are you using a Script Task or a File System Task to do the actual copying?
If you're using a Script Task, the code could be something like:
If Not Dts.Variables("Name of variable containing file name").Value.ToString.Contains("_") Then
' copy file
End If
or
If InStr(Dts.Variables("Name of variable containing file name").Value.ToString, "_") = 0 Then
' copy file
End If
August 19, 2009 at 6:39 pm
You can use something like this in a Script Task:
Dim pdfFiles() as string = System.IO.Directory.GetFiles(theDirectory, "*.pdf", System.IO.SearchOption.TopDirectoryOnly)
then loop through each file and get the ones that don't have an underscore in them.
Alternatively if you are using SSIS 2008 you *may* be able to use Linq (not sure if Linq is available in SSIS 2008) which would eliminate the need for writing the loop manually.
August 20, 2009 at 1:12 am
Thanks guys, Erik Kutzler idea works for me!
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply