watchDirectory Help > Plugins > Environment Variables
Environment Variables
The variables below are available to the .bat file plugin, Run any Program plugin and the
Email plugin.
Please note that the WD_Oxxx variables mentioned are only set when a "rename" event (FILEREN, DIRREN) is detected.
The WD_Oxxx variables pertain to the original name of the file or directory.
Rename events are only fired when you use the Fast monitoring method.
Variable Name | Applicable to Events | Notes | Example value/Usage |
---|---|---|---|
WD_REASON | All | This variable contains the reason why your script was called. When its value is, for example, FILENEW it means your script is called because a new file is created inside the monitored directory. | FILENEW, FILEDEL, FILECHNG, FILEREN, DIRNEW, DIRDEL, DIRREN, QUIET |
WD_DIR | All | This variable contains the directory that is monitored by watchDirectory. | C:\Monitor Me |
WD_FILE, WD_OFILE | All, except "QUIET" | This variable contains the complete name of the file or directory that caused the event. | C:\Monitor Me\SubDir\NewFile.txt |
WD_FILE_D, WD_OFILE_D | All, except "QUIET" | This variable contains the name of the directory where the file or directory causing the event is located. This variable always ends with a backslash (\). | C:\Monitor Me\SubDir\ |
WD_FILE_N, WD_OFILE_N | All, except "QUIET" | This variable contains the name (without directory) of the file or directory causing the event. | NewFile.txt |
WD_FILE_B, WD_OFILE_B | All, except "QUIET" | This variable contains the name (without directory and extension) of the file or directory causing the event. | NewFile |
WD_FILE_E, WD_OFILE_E | All, except "QUIET" | This variable contains the file extension of the file or directory causing the event. This extension is always in capital letters and does not include the dot (.). This variable will be empty for files and directories without an extension. | TXT |
WD_RELDIR, WD_ORELDIR | All, except "QUIET" | This variable contains the "relative directory" of the file causing the event. The relative directory is the path starting at the monitored directory. It will be empty for events directly inside the monitored directory. | SubDir |
WD_FILE_SIZE | FILENEW, FILECHNG, FILEREN | This variable contains the size in bytes of this file. | 1204 |
WD_FILE_SIZE_KB | FILENEW, FILECHNG, FILEREN | This variable contains the size in kilobytes of this file. It has the value of WD_FILE_SIZE divided by 1024. Files with a size smaller than 1024 bytes will have a WD_FILE_SIZE_KB value of 0. | 64 |
WD_FILE_SIZE_MB | FILENEW, FILECHNG, FILEREN | This variable contains the size in megabytes of this file. It has the value of WD_FILE_SIZE_KB divided by 1024. Files with a size smaller than 1024 kilobytes will have a WD_FILE_SIZE_MB value of 0. | 10 |
WD_FILE_SIZE_GB | FILENEW, FILECHNG, FILEREN | This variable contains the size in gigabytes of this file. It has the value of WD_FILE_SIZE_MB divided by 1024. Files with a size smaller than 1024 megabytes will have a WD_FILE_SIZE_GB value of 0. | 2 |
WD_FILE_DATE_CR, WD_FILE_TIME_CR | FILENEW, FILECHNG, FILEREN | These variables will have the creation date (YYYYMMDD) and time (HHMMSS) of the file. | 20070131 |
WD_FILE_DATE_LM, WD_FILE_TIME_LM | FILENEW, FILECHNG, FILEREN | These variables will have the last modified date (YYYYMMDD) and time (HHMMSS) of the file. | 20070131 |
WD_FILE_SHORTPATH | FILENEW, FILECHNG, FILEREN, DIRNEW, DIRREN | This variable contains the DOS 8.3 compatible name of the file or directory. | C:\MONI~001\SUBDIR\NEWF~001.TXT |
WD_FILE_SHORTNAME | FILENEW, FILECHNG, FILEREN, DIRNEW, DIRREN | This variable contains the DOS 8.3 compatible name without directory of the file or directory. | NEWF~001.TXT |
WD_FILE_OWNER | FILENEW, FILECHNG, FILEREN, DIRNEW, DIRREN | This variable contains the name of the owner of the file or directory. | John |
WD_INSTDIR | All | This contains the directory where watchDirectory is installed. | C:\Program Files\watchDirectory |
ANNOTATE | All | This contains the complete path to the wdAnnotate.exe program. See using the wdAnnotate program for more info on the wdAnnotate program. | "C:\Program Files\watchDirectory\wdAnnotate.exe" |
WD_TASKDIR | All | This contains the directory in which your task information is stored. | C:\Documents and Settings\All Users\Application Data\watchDirectory\AutoCopy |
WD_CONFIG | All | This contains the name you assigned to the task. | AutoCopy |
WD_CURRUN | All | This variable contains the unique run number assigned to this task.
The very first time you start a task, this run number will be 1. Together with the WD_CUREVT and WD_CONFIG variables you can use it to construct a unique filename (without risking to overwrite other files). |
117 |
WD_CUREVT | All | This variable contains the unique event number assigned to the current event. This event number is unique for all events of this task (also for multiple runs). | 200 |
WD_EVENTNO | All | This variable contains a unique event number assigned to the current event. This event number is reset for each run (WD_CURRUN) of a task. The first event of a run will have WD_EVENTNO set to 1. Important: This variable is only available for the .bat file plugin, not for the other plugins. |
1 rem call a script only for the first event IF %WD_EVENTNO% EQU 1 Call "C:\Scripts\FirstEvent.bat" |
WD_DATE | All | This variable contains the current date in the format YYYYMMDD. | 20050714 |
WD_TIME | All | This variable contains the current time in the format HHMMSS (24 hour clock). | 165959 |
WD_DTTM | All | This variable contains the current date and time in the format YYYYMMDD HHMMSS (24 hour clock). | 20050714 165959 |