Using Triggers to Automate File Deletion

Demonstrates how to automate file deletion using Triggers module in JSCAPE MFT Server.
  1. Blog
This article was originally posted on March 28, 2012 but was updated on May 31, 2018 to reflect the latest UI.

Overview

If you are familiar with JSCAPE MFT Server you may already be aware of the power and flexibility that Triggers can offer you as an administrator. If you are new to JSCAPE MFT Server, Triggers allow you to automate processes with the use of Event Type parameters and Trigger Actions. Basically, Event Types are predefined events with configurable parameters that represent a condition, when that condition is met it triggers the associated action to be performed. In this article I will show you how to create a Trigger to automate the deletion of aged files and explain how the Trigger accomplishes this task.

Automate File Deletion

We will be creating a Trigger for the specific scenario in which an administrator may want to automate the deletion of files over 30 days old. This could be useful for managing storage space, compliance or simply automating some basic housekeeping. With this Trigger we will use the "Current Time" Event type configured to run once a week. We will specify a particular directory we want this Trigger to look at. We will then use the "Delete Files" Action and configure a Regular Expression within it to look for MS Word documents and PDF files older than 30 days old and delete them.

First, let's create a new Trigger by clicking on the "Triggers" node under the Domain and click "Add". We will give our new Trigger an appropriate name, select "Current Time" from the Event Type drop down and give it a description. Then Click "Next".

add trigger

Now we will specify when we want our Trigger to run. In this example I am configuring this Trigger to run every Sunday night just before midnight. The expression we are using to do this is:

DayOfWeek = 7 AND Hour = 23 AND Minute = 59

We are specifying the day of the week as "7" which means Sunday. The hour and minute is 11:59pm. We can then click the "Test Expression" button and verify if our expression will work. If it does, click "Next".

trigger conditions sunday deletion

Now we are going to add our Trigger Action so click "Add". Select the 'Delete Files' trigger action from the drop-down list, and then click OK.

add delete file trigger action

In this example I will be using this Trigger on the dropzone directory for my server domain. I will be using this regular expression to have this action look for ".doc" and ".pdf" files:

(.*\.doc)|(.*\.pdf)

For more information on using regular expressions in JSCAPE MFT Server Click Here.

We will then set the "Delete Files Older Than (days)" parameter to 30.

You can also select the option to "Delete Empty Directories" which you may or may not want to do.

delete file action parameters

You can continue to add more file types into the Regular Expression if there are more file types you want this Action to look for following the same format you see here. Now you can click "OK" and you should see your Action on the list. You could also create another Action here to look in more directories.

newly added delete files action

Click "OK" once more and your Trigger is now created. Lastly, click "Apply" to enable your Trigger.

Now you have a Trigger created to automatically delete files older than 30 days old in the directory of your choosing on every Sunday at 11:59pm. Feel free to check out some additional articles on Triggers and Regular Expressions that you may find useful.

Downloads

Want to try this out? Download the free, fully-functionalJSCAPE MFT Server Starter Edition.


Download JSCAPE MFT Server Trial