Expression in Foreach Loop in SSIS

  • I have a package that read files from different paths to be processed later in my package. I’m using a Foreach Loop Editor where I indicate the folder path, the file extension and I checked the Full qualified and Traverse subfolders Options in order to get all the files from more than one folder.

    My package works perfect. The problem is that the package reads all the files, even if the files have more than 2 weeks. I can’t delete them because they are populated from another system that I don’t manage, so that option is not a solution for this case.

    I’m planning to add an expression in my Foreach Loop where I can indicate that it reads all the files that are only from today.

    Anyone knows how to set this option? I can’t find which expression option is the correct one.

    Regards,

  • What method are you using to tell that the files are for today? Is there a code in the filename or are you using file date?

    If there is a code in the filename you can likely adjust the pattern of the search. Otherwise you might want to add a script that takes the filename with path and then goes and checks the file date. If it is in the range you want it goes on successful, otherwise it "fails". The downside is that as the number of files grows it will still look at ALL of them. So I hope there is some process to clean them off.

    CEWII

  • I wasa planing to take the File Date System. I really dont know how to set it up.

    My files can have different names, so one way will be to see the date.

  • This may help

    http://msdn.microsoft.com/en-us/library/ms345158.aspx

  • At first blush that looks like a workable solution..

    CEWII

  • Guys,

    I will try it and let you know becasue I will need to change or recreate my actual package.

    Thank you 🙂

  • guys,

    this option works perfect in my package. I dont need to process all the files, only those than are 1 day older to today. 🙂

    I only need to set up the Traverse folder because I cant hard code a path, my process reads subfolders for a main folder... if you have any idea how, I will apreciate it 🙂

  • Pretty easy

    Just add another string variable with the other path and get the array (same like the other path)

    and all the files will be added into the Object Variable

    Thank you

Viewing 8 posts - 1 through 8 (of 8 total)

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