With the release of Cerberus FTP Server 13 we have made an exciting new addition to the Event System: Folder Scanning! This is a new Scheduled Task action that allows a user to manipulate every file in a folder without needing to know the specific files in the folder.

Administrators have previously needed to know ahead of time the names of files for use with actions such as Send a File, Get a File, file operations and others.  This new scheduled task action of Scan A Folder takes in a folder name and generates File Scanned Events for each file in that folder.  From there, these events may be the trigger for Event Rules to perform operations on that file.  With this event’s new ability to specify a condition on the generating task’s name, the rule can be restricted to only occur for a specific Schedule Event.

 

Example of a Scan A Folder Workflow

 

This diagram below gives an example as to how a Scan A Folder workflow might occur. This might be a case of a teacher automating their homework submission folder such that Cerberus FTP Server takes all files uploaded to a folder by midnight and archives them. In this example we have a scheduled task that triggers every night at midnight. The new Scan A Folder action   looks at the uploads folder and sends out a File Scanned Event for each file there. These events are processed in order by the Events System, each time looking for rules that trigger off of the given File Scanned Events.  Here the first rule sends scanned files somewhere, then moves the file to another folder. The second rule only triggers on the last scanned file in the folder, and only when all files have been moved, zips up the directory for archives. If one of the actions (file sends/moves/zipping) errored, the Failure Action will send an email to notify of something occurring.  Otherwise, the location of the archive is sent by http post to another server.

 

Cerberus FTP Server V13 Folder Scanning Automation Diagram

Example Scan a Folder workflow: Scheduled Event w/ Event Rules

 

Defining the Scheduled Task

 

Going into the setup of the example in more detail, the Scan A Folder workflow is broken into two steps. The first step to using this new feature is to define when this action is to occur. We go to the Event Manager / Scheduled Tasks and add a new task.

Just as a normal scheduled event, pick a time you’d like this task to occur, and how often it will repeat.  In the example case, we’d like the action to occur daily at midnight.

 

 

The next step is to create a new action by using the new button and choosing Scan A Folder in the action drop down menu.

Cerberus FTP Server V13 folder scanning folder selection step 1

Cerberus FTP Server V13 folder scanning folder selection step 2

This action has the same top elements as all other actions. An action type and ‘using’ field gets filled in for Scan A Folder. The standard “Stop on Failure” checkbox as all actions have, to determine if processing will continue on to the next action if this action fails.

The first new subsection is “Fail If.” This section helps define what Scan A Folder defines as a terminal failure state, and when it will ignore and continue on to process the next action.  Is a Failure state one where it can’t create an event for every file in the given folder? Or a failure state only if every file scanned fails, continuing on if there is even only one found file.  Or if nothing is processed, then perhaps that is a failure state where you don’t want to send a confirmation email if nothing was scanned.  There is even the case where this is a failure if any one of the event rules that handled the new File Scanned Event returned an error.  These options all work together to determine if this action failed in terms of the prior checkbox.

“Scan Folder Path” is the directory you’d like to scan.  This path must be a directory and Cerberus FTP Server will create a File Scanned Event for each file in that directory.  If you’d like not only the defined folder, but all of its children, simply check the “Recursively transfer all sub-folder content” box.

The filter string is a way to only pick up only a single type of file.  It will append the filter string to the folder path if it’s in the form of *s for wildcard, and ? for single characters.  *.txt will create events for every txt file in the directory for example.

In the example provided, the folder “C:\ftproot\uploads” is the target folder, with either an empty filter string, or a * in the filter string.  This creates a list of four File Scanned Events, one for each of the four files File A-D in the folder.

 

Defining the Event Rule

 

Matching rules to trigger off of this newly created Scheduled Task is the second half of the equation.  From the Event Manager / Event Rules tab, chose to add a new rule.  Then, select a File Scanned Event rule type.

 

Cerberus FTP Server V13 Folder Scanning Add New Rule

Cerberus FTP Server V13 Folder Scanning Add New Rule 2

Here we now have an event that will trigger for every file that’s ever scanned by any scheduled task.  This may be useful, and behaves the same as any other event rule previously created, but is too general for a normal use case.  One suggestion is to match up the newly created rule with the scheduled task defined before.  Here we take advantage of the list of new variables available to a Scanned File Event, and have this rule activate only when the name of the {{TASK}} is the “RunMeDaily” referenced in the example above.

Cerberus FTP Server V13 Folder Scanning Events Condition Matching

This task name check may also check to match more than one task name.  Setting the Matches These Conditions to Match if ANY Filters Match and setting a “RunMeDaily” Scheduled Task, and a “RunMeWeekly” Scheduled Task name.

Some variables to remember might include the {{SETCNT}}, to know the number of files in the Scan A Folder action, the {{SETLAST}} to know the last event in the list of events, both of which allow this rule to only take actions on the last file processed, or only on large jobs. And {{RFP}} the relative directory for the file event in the cases of recursive folders.

The rest of the Event Rule follows the same logic as all other Event Rules, where you can declare File Manipulations, Transfers, Emails, etc. as normal.  The event variables allow you to specify the file name for Send A File action for example.

 

Availability

 

These are just some of the new features that are now available in Web Client in Cerberus FTP Server 13.0 Enterprise edition.  To learn more about all of the new features in Cerberus FTP Server 13.0, check out our release notes here.