This Scheduled Task action 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. Add a folder path to this Scan A Folder scheduled task action and, for each file in that folder, the task will trigger File Scanned Events you have defined in Event Rules. These events can trigger Event Rules to perform operations on the files in the folder. With this event’s ability to specify a condition on the generating task’s name, the rule can be restricted to only occur for a specific Scheduled Task.
Example Scan A Folder workflow
These instructions give 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 CerberusFTP takes all files uploaded to a folder by midnight and archives them.
This example has a scheduled task that triggers every night at midnight. The Scan A Folder action looks at the uploads folder and, for each file there, sends out a File Scanned Event. These events are processed in order by the Events System, each time looking for rules that trigger off of the given File Scanned Events. In this example, 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 archiving. If one of the actions (file sends/moves/zipping) fails due to an error, the Failure Action will send an email to notify the administrator. Otherwise, the location of the archive is sent by HTTP post to another server.
Defining the Scheduled Task
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. Navigate to Event Manager > Scheduled Tasks and click the 'New' button to add a new task.
Define a time for this task to occur, and how often it will repeat. In this example case, the action will occur daily at midnight.
Create a new action by using the new button and choosing Scan A Folder in the Action: drop-down menu.
This action has the same top elements as all other actions: An action type and ‘using’ field gets filled in for Scan A Folder and is not editable and the standard “Stop on Failure” checkbox as all actions have, which determines if processing will continue to the next action if this action fails.
The first subsection is “Fail If.” This section helps define what Scan A Folder should consider a terminal failure state, and when it will ignore and continue 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 is it a failure state only if every file scanned fails, continuing 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 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 * for a wildcard, and ? for single characters. For example, *.txt will create events for every text file in the directory.
In the example provided, the folder “C:\ftproot\uploads” is the target folder, with either an empty filter string or a wildcard * 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
Next, you will create a rule that will be triggered off of the Scheduled Task. Navigate to Event Manager > Event Rules and click 'New' to add a new rule. Then, select a File Scanned Event rule type.
To tell Cerberus which rule to trigger when the Scheduled Task runs, in the Rule Conditions, use the {{TASK}} variable == (equals) the name of the “FolderScan” Scheduled Task you set up above.
This task name check may also check to match more than one task name. For example, setting the Matches These Conditions to Match if ANY Filters Match and setting a “RunMeDaily” Scheduled Task, and a “RunMeWeekly” Scheduled Task name. In this example this rule is triggered by two different Scheduled Tasks, one that runs every day and one that runs once a week.
Some variables to remember might include the {{RFP}} the relative directory for the file event in the cases of recursive folders, the {{SETCNT}}, or ‘Set Count’ variable, to know the number of files in the Scan A Folder action and the {{SETLAST}}, or ‘Set Last File’ 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. Note that the ‘RFP’ variable in this task is not the same as the ‘Remote File Path’ variable in other Cerberus rules. Below is a complete list of the variables available for this rule type:
Variable | Definition |
{{T}} | Timestamp |
{{LFN}} | File Name |
{{LPNT}} | Local File Parent Directory |
{{LFP}} | Local File Path |
{{RFP}} | Relative File Path |
{{DIR}} | Is a Directory |
{{SZ}} | File Size |
{{TASK}} | Task Name |
{{SETCNT}} | Size of Scanned File Set |
{{SETPOS}} | Position of Scanned File Set |
{{SETLAST}} | Last File of Scanned File Set |
Once you have defined the rule conditions, in the 'Action' section, you can define what you would like this rule to do. See Creating and Editing Event Rules for more details.
Comments
0 comments
Please sign in to leave a comment.