How to set up process execution triggers

CompleteFTP supports highly customizable process execution triggers. This means that when an event such as a file upload occurs, a process can be launched (e.g to move a file after it has been uploaded).

Process control

In the Process Execution tab, the maximum number of concurrent processes can be set (default 10), together with the maximum run time and maximum time a process is queued for before it runs. The latter two setting have a default of 0 which means no limit.

Creating and editing triggers

The list of current process triggers is displayed in the Process Execution tab. Use Remove to delete triggers, and Add to create a new trigger.

When adding, enter an appropriate name for the trigger, and select what Events the trigger is applicable for. The various fields are described below.

Events

Processes may be triggered by any of the types of events listed below. By default events are only triggered when an operation, such as a file upload, succeeds, but they may also be triggered on failure. This is determined by the checkboxes labelled 'Trigger on success' and 'Trigger on error'.

Scheduled
Events occur at a predefined schedule, such as once per hour or at midnight every weekday. See here for details. Since this event is not related to any particular session macros related to users and files are not available.
Upload file
When a file has been uploaded. All macros are available.
Download file
When a file has been downloaded. All macros are available.
Delete file
When a file has been deleted. All macros are available.
Move file
When a file has been renamed or moved. All macros are available.
Create folder
When a new folder has been created by a user. All macros are available.
Delete folder
When a folder has been deleted by a user. All macros are available.
Move folder
When a folder has been renamed or moved by a user. All macros are available.
Log in
When a user logs in. All macros are available.
Log out
When a user logs out. All macros are available.

Filters

The folder- or file-path filter should be entered. This filter may be used to select the files/folders which the notifications should be sent for. For example, if notifications should only be sent for files with the extension, '.dat', then the filter should be set to '*.dat'. By default Windows-style wildcards are used for matching.

Note that the full path is used for matching; not just the file-name. So if notifications should be sent for files named 'test.dat' in any directory, then the filter should be set to '*/test.dat'.

Regular expressions (.NET-style) may also be used. To use these the filter should be prefixed by 'regex:'. Information on .NET regular expressions may be found on the Microsoft(tm) website. Note that multiple filters may be defined using regular expressions using the syntax, regex:^(/Folder1/.*|/Folder2/.*), which would match anything underneath the folders, /Folder1 and /Folder2. If you want to match anything not underneath these folders you can do that using the regular expression, regex:^(?!/Folder1/.*|/Folder2/.*).

Type

Three types of process triggers can be created. They can either be a normal program (an executable file such as cmd.exe), a DOS batch script or a Powershell script. The settings for these triggers are described below:

Program file

Only applicable for Programs. This is the path to the executable that will be launched. Note that a program with a GUI should NOT be specified.

Arguments

Enter the arguments to be supplied to the program. Various macros can be used here.

Script

Enter the batch script, Powershell or FTP script to be run. Various macros can be inserted into the script at execute time.

Working directory

Select the working directory that the program or script should be running in when it is executed.

Examples

For both the examples below, if they are to apply to all uploaded files, use "*" as the filter. Otherwise use a specific directory, e.g. for a certain user, /home/username/*. Note that in the scripts the Windows paths must be used rather than the virtual filesystem paths.
To move all uploaded files to a single directory after upload (as a batch file):

move "%WindowsPath%" D:\destination

To change files to readonly after uploading:

attrib +r "%WindowsPath%"