Delete a list of files of an specified size using the Advanced SSIS File System Task in SSIS

In this article, we will show you two ways to delete files greater than 10 MBs using our Advanced File System Task. For additional information about the task, you can refer to our dedicated article here.

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 > 10000000 to filter files larger than 10 MBs.
    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.

  • Use the variable for the file path and select the action Delete file.
    Advanced File System Task Delete files with a variable in the path
  1. Run the package, and it will delete files above 10 MB in size.
    Delete files example 1

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

Method 2: Using the Delete Option with the Filter

  1. Drag and drop an Advanced File System Task.
  • Select the option Delete files and choose the folder you want.
    Advanced File System Task Delete option example 2
  1. Go to the Filter and Sorting tab and use the expression Size > 10000000 to filter files larger than 10 MBs.
    Advanced File System Task filter size example

  2. Run the package, and it will delete files above 10 MB in size.

Using either method, you can efficiently delete files based on your size criteria. If you encounter any issues or need further assistance, feel free to contact our support team via chat on our website or through email at support@zappysys.com.