How To Get Your MFT Server Email You A List Of Old Files

Posted by John Carl Villanueva on Wed, Sep 30, 2015 @ 08:46 AM


We already taught you how to set up your MFT server to automatically delete old files and zip old files. Would you like to learn how to generate a list and then receive an email of that list as well? If so, read on.


What we're trying to do

This task can actually be broken down into three parts:
  1. Scanning a directory and its subdirectories for old files;
  2. Listing down the paths of those files into one file; and
  3. Emailing that list to you. 


How to implement that on JSCAPE MFT Server

Ok. This is how we're going to achieve all that on JSCAPE MFT Server:

1. We'll create a directory monitor that would scan a directory and its underlying subdirectories for aged files;

2. After that, we'll create a trigger that would activate the directory monitor at some specified time; 

3. Next, we'll create a second trigger that would generate a list of all old files that are found; and 

4. Lastly, we'll create one more trigger that would email that list to you.

Steps 1 and 2 have already been covered in the article "How To Delete Old Files From Your Server", so I suggest you read that first. Just read up to Step 2 in that post and then come back here.

Done already? Let's proceed with Step 3 then. 


Generating a list of old files

Create a new trigger  and give that trigger a name (e.g. "List Old Files"). Expand the Event type drop-down list and then select "Directory Monitor File Aged". This will enable this trigger to listen to the Directory Monitor File Aged event, which will cause this trigger to fire each time an aged file is found. Click Next to proceed.



Normally, when the server scans for old files, it would include both files and subdirectories in its search results. If you don't want to include directories in your list, just enter the expression:


IsDirectory = False


In case you have two or more directory monitors that raise the Directory Monitor File Aged event, you should add an expression that would limit this trigger's response to the right event. To do that, just specify the directory monitor name. So the complete expression would be:


IsDirectory = False AND Monitorname = "Year Old Files"


wherein "Year Old Files" is the name of the directory monitor we created in the article How To Delete Old Files From Your ServerIf another directory monitor happens to raise the Directory Monitor File Aged event, this trigger wouldn't act on it.

For a complete list of variables supported by this particular trigger, just click the Variables button.

Click Next to proceed.



We're now ready to add a trigger action that would append each search result (consisting of a complete file path) into your list. Click the Add button to create a new trigger action. 



We would need the Append File for this purpose, so select that action and then click OK.



The next step would be to specify the file that would hold the list. For this example, we have named our file "oldfiles.txt". You can use the Browse button and then navigate to your desired file. 

Once you've selected the file, enter the %File% variable into the Message box. For this particular trigger, the %File% variable would hold the path of each old file found. Click OK to proceed.



To clarify, each time the server finds an old file in the monitored directory, it will:

  1. Raise the Directory Monitor File Aged event. That event will in turn cause the server to:
    1. Store the old file's path into the %File% variable and
    2. Fire this trigger. 
  2. Next, the server will compare the directory monitor's name with the one specified in the trigger's condition expression.
  3. If the directory monitor's name matches the one specified in the trigger's condition expression (i.e., "Year Old Files"), it will execute the Append File trigger action. Upon execution, the Append File trigger action will append the path currently stored in the %File% variable into the designated file, i.e., "oldfiles.txt". 

This process will then repeat for every old file found. And that's how the list is generated. 



Click each succeeding OK button until you get back to the main screen. Upon reaching the main screen, click the Apply button to finalise the trigger creation process. 


Emailing the list 

Now that you've created a trigger for generating your list, the last step would be to create a trigger for sending that list in an email. 

Create a new trigger and give that trigger a name (e.g. "Email List of Old Files").

Expand the Event type drop-down list and select Current Time

Click Next to proceed.



For this example, we would like this trigger to fire an hour after the scan. That should give the server ample time to look for old files in the monitored directory. Since the scan is scheduled to run at 9:30 PM, we'll let the email sending take place at 10:30 PM. To do that, we simply enter the expression:


(Hour = 22) AND (Minute = 30)


Click Next to proceed.



Add a new trigger action. 



And select the Send Email action. 



Enter all pertinent information for the email into their respective fields. 



Don't forget to attach the file containing the list of old files. 



Click OK til you're back at the main screen. 



Once you're back at the main screen, click the Apply button to finalise the trigger creation process. 

That's it. Your MFT server would then be ready to scan for old files at the predefined schedule, list all old files that are found, and then email that list to you. 


Get started

Want to try this out yourself? Download the free, fully-functional evaluation edition of JSCAPE MFT Server now. 



Download Now


Topics: JSCAPE MFT Server, Managed File Transfer, Business Process Automation, Triggers