Triggers: file

Launches the macro when a file in the specified folder is added, removed, renamed or modified. To assign this trigger, use the Properties dialog.


QM watches for changes in the specified folder. The folder can be local or network folder or drive.


By default, QM watches for changes on all files within the folder. You can use "Include files" and/or "Exclude files" fields to filter files you need. You can specify one or more filenames or filename patterns with wildcard characters * and ?. To specify several filenames or patterns, use | separator. For example, use "test.txt" to watch for changes on file "test.txt"; use "*.txt|*.ini" to watch for changes on all text and ini files. Filenames can optionally include path relative to the watched folder, e.g. "subfolder\test.txt". A filename is compared as containing relative path if it contains \.


Sometimes Include/Exclude fields may not work as expected because QM may receive short (DOS) filename (e.g. "C:\PROGRA~1\SOMEFI~1.TXT" instead of "C:\Program Files\Some File.txt"). This depends on what filenames uses the program that works with the file. Before evaluating include/exclude fields, QM converts short filename to long filename on Added and Modified events (QM 2.2.0). It is impossible to convert on Remove and Name Changed events because the file already does not exist. To make the trigger independent from this, in Include/Exclude fields use only extension (e.g. "*.txt"), or part of filename (e.g. "some*.txt"), or both long and short versions ("some file.txt|somefi~1.txt").


In the list box, select what changes will cause the macro to run:

Added - a file is created, moved or copied into the watched folder.

Removed - a file is deleted or moved out.

Name changed - a file is renamed.

Modified - any changes on file times, attributes, size and security attributes. For example, if file content changes, the modified time is changed. Note: the last access time precision is very low, and therefore the macro will not be launched each time if you only select Time Accessed.


QM automatically starts/stops watching network and removable drives when they become available/unavailable.


Duplicate "Modified" events are joined to single event.


The macro can receive trigger information through the function statement:


function event $name [$newname]


event - 1 on added, 2 on removed, 4 on name changed, 8 on modified.

name - file name, including path.

newname - on name changed, this is new name, including path. On other events, newname is empty.