Skip to main content

File Trigger

Start a Process when a file or files are written to a disk.

Ossi Galkin avatar
Written by Ossi Galkin
Updated over a year ago

File (watch) Triggers are triggered when a file matching the File filter is saved to the Directory path that is watched.

The Trigger is watching for new files added to the watched directories, e.g., a newly created file will cause the Trigger to launch a Process, but if that file is left in the directory and modified, that will not cause a new execution. The file watch also checks the files in the directory every 10 seconds. 

The Trigger keeps track of files it has already processed by their file names. This means that it will not notice if you e.g. overwrite the file, or quickly delete a file and then create a new one with the same name. It may take up to the max poll delay of 10 seconds to notice a file has been removed.

NOTE: It is recommended to always clear the files from the watched directories after processing, because keeping track of them takes up resources. If you would have thousands of files in the folder, the processing may slow down. 

NOTE: In an HA Agent Group, the watched directory should be accessible from all the Agents in the same Agent Group. Otherwise the other Agents will see the file as missing from the watched folder and remove it from tracking causing the file to be processed again.

File watch Triggers can define:

  • Name  – Descriptive name for the Trigger.

  • Directory  – Directory path of the files that will be fetched.

  • File filter  – File filter to use (e.g. '*.xml'). Wildcards are described here.

  • Include sub directories  – If enabled, fetches all the matching files also from sub-directories.

  • Maximum number of files to process at a time –  Maximum number of files to process at a time.  The Trigger will process max 1000 files at a time.

  • Quiet period in seconds – Time in seconds, the Trigger will wait since the last file write time before processing the file. NOTE: the operating system may not always update the last write time for a file for performance reasons. Therefore always set the value to be large enough to take this into account when using this setting.

  • Poll interval in seconds –  Time before files are processed again.

  • Username  – If the username field is used the File Trigger will not use the Frends Agent account credentials to poll for files but a different account. The expected input is domain\username.

  • Password  – The password for the user above.

File Trigger parameters, specifically Name and Directory,  are not Text or Expression fields familiar from the other Process elements. Instead they behave like Text fields, with the exception that you can use Environment Variables without Handlebars. For example if you have C:\EaiFiles stored in Environment Variable #env.EAI, then you could have Directory configured as #env.EAI\In. It would then watch folder C:\EaiFiles\In.

Once the process is triggered by a file, the file paths are available to the process via the #trigger.data.filePaths. It is array System.Object[] containing strings (file paths). For more details, there is also the #trigger.data.files reference, which returns an array of objects with the following properties:

  • FileChangeType - Always "Created".

  • FullPath  - Full path to the file.

  • FileName  - Name of the file.

Did this answer your question?