Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6890153
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:14:46+00:00 2026-05-27T06:14:46+00:00

I have a folder which gets a daily dump of 7 or 8 .xls

  • 0

I have a folder which gets a daily dump of 7 or 8 .xls files. Among all those files, I just need to load 2 files with a specific name.. ABC_datestamp.xls and XYZ_datestamp.xls.

The problem is I am not able to isolate these 2 file names because there are so many other files in the same folder. The second challenge is that my manager wants me to load all files from last week at once, which means I have to specifically load files from last 7 days only.

Right now I am copying those specific 7 files in to a folder and then loading it using a for each loop container.

Is there anyway, I can use a script task to generate the file names like ABC_02-Dec-2011.xls, ABC_01-Dec-2011.xls, ABC_30-Nov-2011.xls …….last 7 days files and pass it as a variable to a DATA FLOW TASK?

Any better suggestions ?

I know a lot of people have asked similar questions but I am new to SSIS and not able to find good answers.

Thanks a lot..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T06:14:46+00:00Added an answer on May 27, 2026 at 6:14 am

    Rather than try and build a list of all possible file names, I’d loop through all the files in the folder and use a Script Task to determine which files to process further.

    The control flow would look like this:
    screenshot of foreach loop container

    with FELC_InputFolderContents‘s variable mappings set thusly:
    screenshot of foreach loop container settings

    SCR_SetProcessFileFlag‘s configuration:
    screenshot of script task settings

    SCR_SetProcessFileFlag‘s script like so:

        public void Main()
        {
            string targetFileFullPath = (string)Dts.Variables["User::TargetFileFullPath"].Value;
            string targetFileName = Path.GetFileName(targetFileFullPath);
            Dts.Variables["ProcessFileFlag"].Value = IsValidFileName(targetFileName);
            Dts.TaskResult = (int)ScriptResults.Success;
        }
    
        private bool IsValidFileName(string targetFileName)
        {
            bool result = false;
            if (Path.GetExtension(targetFileName) == "xls")
            {
                string fileNameOnly = Path.GetFileNameWithoutExtension(targetFileName);
                if (fileNameOnly.Substring(0, 4) == "ABC_" || fileNameOnly.Substring(0, 4) == "XYZ_")
                {
                    string datePart = fileNameOnly.Substring(4);
                    DateTime dateRangeStart = DateTime.Today.AddDays(-7);
                    DateTime dateRangeEnd = DateTime.Today;
                    DateTime fileDate;
                    if (DateTime.TryParse(datePart, out fileDate)) 
                    {
                        if (dateRangeStart <= fileDate && fileDate <= dateRangeEnd)
                        {
                            result = true;
                        }
                    }
                }
            }
            return result;
        }
    

    and the precedence constraint between SCR_SetProcessFileFlag and DTT_ProcessSelectedFile configured thusly:
    screenshot of precedence constraint settings

    (Obviously, the specific logic for IsValidFileName depends on your particular requirements.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a bat script in which gets all files in a folder and
I have a bunch of .doc files in a folder which I need to
I have a winform project which lists all the files in a specified folder.
I have a folder which has many files. Files are continually being dropped into
We have a NET app that gets installed to the Program Files folder. The
I have a thread which polls a folder for new files. The problem is
I have folder on which i want to apply security like the current user
I have a content folder which is full of other sub-directories named in the
I have a folder foo which resides under the root folder of my ASP.NET
I have a image folder which contains sub directory for each album of images

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.