Add Folder Trigger (script step reference)

By April 1, 2020May 26th, 2020Online Help, Troi Activator Plug-in
Activator Plug-in for FileMaker Pro

Add Folder Trigger

Add a folder action, which will trigger a script when the monitored folder is changed.

SyntaxScript step badge

Add Folder Trigger [ Select ; Result (error) ; Folder path ; File name ;
                     Script name ; Trigger for ; Switches ]


Select entire contentsreplaces the entire contents of a field with the result. If not checked the result replaces the currently selected portion of the field
Result (error)an error code
Folder paththe path of the folder which needs to be monitored for changes
File namethe name of the FileMaker file that contains the script
Script namethe name of the script to trigger when a change in the folder occurs
Trigger forspecify if you want to trigger for files, folders or for both
Switchesfurther modify the behavior of this step


Switches can be left empty or set to this switch:

-AddedItemsOnlyonly trigger a script when an item is added (not when an item is removed from the folder or modified)

Returned Result

Data type returned

Error code


The returned result is an error code. An error always starts with 2 dollars, followed by the error code. You should always check for errors. Returned error codes can be:

0no error
$$-50paramErrthere was an error with a parameter
$$-120dirNFErrthe monitor folder could not be found
$$-4295maxFolderTriggersErrthe maximum number of folder triggers is already running

Other errors may be returned.

Originated in

Activator Plug-in 6.0


FileMaker Pro 16 to 19


The script parameter of the triggered script will contain all the information on what was changed in the folder. This is a return separated list, containing a multiple of 2 lines, where the first line will contain what action happened, for example ADDED or REMOVED. The next line contains the path to the file or folder that was changed. The path is a fully qualified path compatible with FileMaker Pro’s paths, on macOS a path will be formatted like this:


on Windows it is formatted like:


NOTE the script might be triggered multiple times when multiple items are changed, with each ScriptParameter containing only a part of the change information.

Possible returned actions can be: ADDED, REMOVED, MODIFIED, RENAMED_OLD_NAME and RENAMED_NEW_NAME.
When a file or folder is renamed you will first receive the RENAMED_OLD_NAME action with the old path, followed with the RENAMED_NEW_NAME action and the new name.

NOTE You don’t need to delete any trigger data, all data comes in via the script parameter.


Add Folder Trigger [ Select ; Result: $ErrorCode ; Folder path: "/MacHD/incomingData/"  ; 
                     File name: "FolderMonitor.fmp12" ; Script name: "Folder_TriggerScript" ; 
                    Trigger for: Files and Folders ; Switches: "" ]

This will start to monitor the folder “/MacHD/incomingData/”. When there is a change in the monitored folder (like a file or folder is added to this folder), it will trigger the script “Folder_TriggerScript” in file “FolderMonitor.fmp12”. Note that this example is somewhat simplified, normally you should not use a hard coded filename like in the above example.

When the script “Folder_TriggerScript” is run, use Get( ScriptParameter ) to get detailed information on what was changed in the monitored folder. The script parameter might contain for example this text with 4 lines (on macOS):


on Windows ScriptParameter might contain:


This indicates that the file new_report.pdf was added to the folder and the folder stale_folder was removed.

Example 2

Create a trigger script called Folder_TriggerScript. Add the following script steps to your script:

Enter Browse Mode
# Get the data from the script parameter
Set Variable [ $ScriptParameter ; Get ( ScriptParameter ) ]
# We are getting each pair of information out in a loop and store it 

Set Variable [ $index ;  1 ]
	# Get the action first
	Set Variable [ $Action ; GetValue ( $ScriptParameter ; $index ) ]
	# Now get the path:
	Set Variable [ $Path ;  GetValue ( $ScriptParameter ; $index + 1 ) ]
	# If $Action and/or $Path is empty, there are no more lines of information, and we are done:
	Exit Loop If [ $Action = "" or $Path = "" ]

	# We have a new change, store it into the database: 
	New Record/Request
	Set Field [ folderEvents::ActionType ; $Action ]
	Set Field [ folderEvents::Path ; $Path ]

	# ** Add your own stuff here. ** 
	# Point the index to the next pair:
	Set Variable [ $index ;  $index + 2 ]
End Loop
Go to Field[ ]
Exit Script [ Result: 0 ]

To start monitoring you can create a “Start Folder Monitor” script. Add the following script steps:

Set Variable [ $DesktopFolderPath ; Get ( DesktopPath ) ]

Add Folder Trigger [ Select ; Result: $ErrorCode ; Folder path: $DesktopFolderPath ; 
                File name: Get ( Filename ) ; Script name: "Folder_TriggerScript" ; 
                Trigger for: Files and Folders ; Switches: "" ]

This will start monitoring the wanted folder (in this example the Desktop folder). When running on Windows and you rename a file this will trigger the script and result in this ScriptParameter:


Related script stepScript step badge

Remove Folder Trigger

Related functionFunction badge


Related topics

Activator Plug-in online help (overview)

Online Help Page for Activator Plug-in for 15 to 19 –> Add Folder Trigger (actrp7626) 2020-0526 20:17:43