SSIS : Move files over 3 months old to another folder

kkran 831 Reputation points

Hi Everyone :
I already have an SSIS package with user: src_file_path variable with value E:\ETL\Data Load\Act_DrugTool\Part1\DEV\Outgoing\

In the above path there will be files in the below format excel files :

I want to create another variable called user: archive_file_path and move the files from Source variable file path if the file is more than 3 months old.

I want to read the date from the file name in the source variable path and if the file is more than 3 months old move to the archive path below : Archive : \Sdcpifil011\etl\Legacy_ETL_Data_Loads\ETL_SSIS_ACTDrugTool\Part1\PROD\Archive

Will it be a script task or file system task ? Thanks in advance for your help.

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
12,851 questions
SQL Server Integration Services
SQL Server Integration Services
A Microsoft platform for building enterprise-level data integration and data transformations solutions.
2,462 questions
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,559 questions
0 comments No comments
{count} votes

Accepted answer
  1. Monalv-MSFT 5,896 Reputation points

    Hi @kkran ,

    We can use Foreach Loop Container to find the files, then use empty Sequence Container, Precedence Constraint, File System Task to move the files to archive folder.

    Please refer to the following pictures:




    DATEDIFF( "mm", (DT_DBDATE) (SUBSTRING( RIGHT( TOKEN( TOKEN( @[User::FileName] , ".", 2 ), "_", 1 ) , 8 ) , 1, 4)+"-"+  
    SUBSTRING( RIGHT( TOKEN( TOKEN( @[User::FileName] , ".", 2 ), "_", 1 ) , 8 ) , 5, 2)+"-"+  
    SUBSTRING( RIGHT( TOKEN( TOKEN( @[User::FileName] , ".", 2 ), "_", 1 ) , 8 ) , 7, 2)), GETDATE())>3  

    Best Regards,


    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Yitzhak Khabinsky 25,201 Reputation points

    Will it be a script task or file system task ? Thanks in advance for your help.

    SSIS File System Task doesn't have functionality sufficient enough for your needs.
    So, it should be SSIS Script Task.

    0 comments No comments