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
- 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.
-
Go to the Filter and Sorting tab and use the expression
Size > 10000000
to filter files larger than 10 MBs.
-
Drag and drop a Foreach Loop Container.
- In the Collection tab, use the Foreach ADO Enumerator option and select the variable used to save the file list.
-
In the Variable Mapping tab, select a string variable to get the full path from the FileList variable.
-
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.
-
Run the package, and it will delete files above 10 MB in size.
-
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
- Drag and drop an Advanced File System Task.
- Select the option Delete files and choose the folder you want.
-
Go to the Filter and Sorting tab and use the expression
Size > 10000000
to filter files larger than 10 MBs.
-
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.