Friday, January 29, 2016

Remove Old Files - Schedule It

In previous part one and part two I described how to create and export rules from MSH Delete Files Older Than application. 

In this part it’s time for auto scheduling. 

Application doesn’t have built-in scheduler so we need to use the standard one from Microsoft Windows. Open Start Menu | All Programs | Accessories | System Tools | Task Scheduler application. Click right mouse button on Task Scheduler Library and select Create Basic Task

Set task name, something like: Remove old files from C.

Create a Basic Task - Task Scheduler

Click Next button, I would like to remove files weekly, so select Weekly option and click Next button. 

Application should remove files on each Monday at 00:00 starting from 1st of February.
Weekly Trigger - Task Scheduler

Go to the next page and leave Start a program option, on the next page click Browse button and select MSH Delete Files Older Than.exe application. In arguments field put -f c:\data\settings.xml parameter. 

Last page will show you a summary information about your settings. Click Finish button. 

Now everything is set up and your operating system will be responsible of running the application on defined time. So if you want to keep your files organized take a look and visit MSH Delete Files Older Than web site.

Wednesday, January 27, 2016

Export Auto Delete Rules

In the part one I described how to create a rule to remove files older than 7 and 30 days. Main goal is to schedule this action to delete files once a day.

Before Windows built-in scheduler could be used we need to export rules from the application.

When application start click Options button and select Export Rules menu.


Save file as window will open.

Using save as window choose where to store rules.


By default filename will be settings.xml, it could be changed to something more meaningful. I will leave it as is.

Choose directory where exported rules will be saved, for example c:\data\settings.xml, click Save button. Rules are exported now.

In the part three we will see how to use scheduler to make an automatic deletion.

Monday, January 18, 2016

Delete Old Files and Remove Empty Folders

If you ever wanted to automatically remove older files than (n) days in multiple directories you probably struggle with batch and PowerShell scripts or even with manual deletion using explorer.

Sample scenario

We have the ftp server with users’ directories and one public directory so everyone could write to it. Users’ files should remain 30 days and files from public directory only for 7 days.

Empty directories should be purged.

Solution

Download MSH Delete Files Older Than, unzip compressed file, run the EXE application. No installation is needed.

Delete Files Older Than software after first run.

Click Add button to open Rule wizard. First we need to specify which folders should be cleaned, start with public folder. Click Add button then Browse and choose public directory. Select Include sub folders and Delete empty folders option.

Switch to Time page. Leave modification time option in Match files by criteria. Our directory should be cleared from files older than 7 days. Select Match files which are OLDER than 7 DAYS.

Switch to Files page. We want to remove all types of files, but if there will be requirement to remove only specified files, we could define which file names should be deleted.

Switch to Action page. Now we need to define what to do with old files. By default files are deleted permanently. We could also move them to recycle bin, move or copy to other directory and even compress while copying. Leave Delete files permanently option.

Switch to Name page. Change rule to name to something meaningful, like Remove files from public directory. Click OK button.

Now it's time for users' directories. Once again click Add button to edit new rule. Go through each page like when we were defining rule for the public directory. Just change 7 to 30 days on Time page.

Actions which could be done on old files.


Summary

In this post I tried to describe how rules could be created to delete files in different directories and with different time frame.

Defined rules can be now start manually by clicking Run button or scheduled to run automatically on defined time.

Monday, January 11, 2016

Postfix: Rewrite Message Subject Based on Recipient

Problem

Some time ago user had a problem because his company switched to a new email-to-fax service. They had a security implementation that require to append to each email sent to them a fax number. Number must be added at the beginning of the message subject. He wanted to automate this step so users don't need to remember and manually add number to subject.

So the requirement is that messages which are sent to fax@super-service.com must have subject in format:

123-555-789: Message subject.

Where Message subject is an original message subject before modifications and 123-555-789 is a fax number.

Solution 

We need to create a rule with Message Recipient condition and Modify Message action.

  1. Go to [Server] > Rules > Default Rules and click Add Rule button. 
  2. In new opened window, go to Actions tab and click Add button, choose Modify Message Subject menu. 
  3. Now define how subject will look like after rewrite. Based on our requirement is should be in 123-555-789: $SUBJECT format. Were $SUBJECT is a value which will be replaced with message subject. 
  4. Go to Conditions page and click Add button, select Message Recipient menu. 
  5. Enter a recipient email address: fax@super-service.com. Select in which fields address will be searched. 
  6. On the Name page set a rule name, it should be a name which briefly describe actions made by this rule, for example: Modify subject for fax service
  7. Click OK button, then Save All to save current settings. 
Rule wizard provide many variations of actions, ie. Modify Message Subject.

Summary 

Now when someone will send a message to fax service email address to the message subject fax number will be added.

MSH Traffic Policy is a milter application for popular mail servers which extends theirs mail flow. To learn more about MSH Traffic Policy for Zimbra, Postfix and Sendmail visit official website.