How to copy files in SSIS from a size range

Introduction

This article teaches how to use the Advanced File System to copy files from a folder with a size of ‘x’ MB to a size of’ y’ MB.

We will use the ZS Advanced File System task to detect the files between 5 to 20 MB.
Then, we will copy the files from that list.

Prerequisites

Steps

Method 1: Using Foreach Loop Container

  1. Drag and drop an Advanced File System Task with the following configuration:
  • Select the option Get file list as ADO.net Data Table.
  • Choose a folder and a variable to save the result.
    Advanced File System Task Get file list as ADO.net data table option
  1. Go to the Filter and Sorting tab and use the expression Size > 5000000 AND Size > 20000000 to filter files between 5MB and 20MB.
    Advanced File System Task filter size example

  2. Drag and drop a Foreach Loop Container.

  1. In the Variable Mapping tab, select a string variable to get the full path from the FileList variable.
    Foreach Loop container variable Mappings

  2. Drag and drop another Advanced File System Task inside the Foreach Loop Container.

  1. Run the package, which will copy files between 5MB and 20 MB.
    Copy files example 1

  2. Optionally, use a Logging Task inside the Foreach Loop Container to save the copy file information in a file.

Method 2: Using the Copy Option with the Filter

  1. Drag and drop an Advanced File System Task.
  1. Go to the Filter and Sorting tab and use the expression Size > 5000000 AND Size > 20000000 to filter files between 5MB and 20MB.
    Advanced File System Task filter size example

  2. Run the package, and it will copy files between 5MB and 20 MB.

Conclusion

Following these steps, you can easily use functions for your file paths in SSIS. For further assistance or inquiries, contact our support team via chat on our website or through email at support@zappysys.com.

Reference

For more detailed information, refer to our Format Specifiers / Placeholder Functions article.