|Purpose:||Monitor folder and/or file creation, modification, and deletion|
|Format:||FOLDERMONITOR [/C [folder]]|
FOLDERMONITOR [/=] /Wn /S folder /I"file" /E"file" /U CREATED DELETED MODIFIED RENAMED n command
|folder||Folder (directory) or file name|
|CREATED||Execute the command if the folder or file is created|
|DELETED||Execute the command if the folder or file is deleted|
|MODIFIED||Execute the command if the folder or file is modified|
|RENAMED||Execute the command if the folder or file is renamed|
|n||Number of repetitions (or FOREVER)|
|command||Command to execute when condition is triggered|
File Completion Syntax:
The default filename completion syntax is: [/s] dirs [/c] dirs [1*] *
If you don't enter any arguments, FOLDERMONITOR will display the folders and files it is currently monitoring, in the format:
folder (include/exclude) condition (n) command
The command line will be parsed and expanded before FOLDERMONITOR is executed, so if you want to pass redirection characters or variables to command you will need to protect them (by enclosing in single back quotes, doubling the %'s, or using command grouping).
The MODIFIED condition is set if the file's size, attributes, or last access date and time are changed.
If you want to monitor multiple conditions for a file or folder, put them into a single FOLDERMONITOR command. FOLDERMONITOR creates a separate thread for each FOLDERMONITOR command, so if you have multiple commands you will be wasting CPU time, RAM, and risk having command executed simultaneously in different threads.
If the last argument on the line is a single (, it is interpreted as the beginning of a command group. FOLDERMONITOR will append the following lines (in a batch file) or prompt you for more input (at the command line) until it gets a closing ).
When the condition is triggered, the command will be executed immediately in the separate thread. This may cause problems if you try to write to the display or access files while the main TCC thread is also performing I/O. You may need to use START or DETACH in command to avoid conflicts.
FOLDERMONITOR creates several environment variables when a file or folder is created, deleted, modified, or renamed that can be queried by command. The variables are deleted after command is executed.
|_folderaction||The type of change to the file or folder. The possible values are:|
|_foldercount||The number of times the condition has been triggered|
|_foldername||The name of the folder being monitored|
|_folderfile1||The name of the file or folder that was created/deleted/modified/renamed. If the file was renamed, folderfile1 is the old name.|
|_folderfile2||If a file was renamed, folderfile2 is the new name|
|_foldertime||System time when the change occurred.|
To monitor your d:\results directory and copy any new or modified files to a web page:
foldermonitor d:\results created modified forever copy "%%_folderfile1" "http://mycompany.com/results/"
|/=||Display the FOLDERMONITOR command dialog to help you set the command line options. The /= option can be anywhere on the line; additional options will set the appropriate fields in the command dialog.|
|/C||If name is specified, remove the monitor for that folder. Otherwise, remove all folder / file monitors. /C cannot be combined with any other options.|
|/E||Filename to be excluded. If you want to exclude multiple files, use multiple /E options. If you want to exclude a file in a specific subdirectory, the filename should include the relative path from the folder name. The name can include wildcards.|
|/I||Filename to be included. If you want to include multiple files, use multiple /I options. If you want to include a file in a specific subdirectory, the filename should include the relative path from the folder name. The name can include wildcards.|
|/U||Don't set the trigger until the file is unlocked. Not compatible with CREATED, because FOLDERMONITOR will always get the notification before the file is accessible.|