Monitor FTP sites with WatchFTP Monitor FTP sites with WatchFTP


 

Environment Variables

These variables are available for use in your Batch Script. You can also include them in automatically generated emails if you select Separate Email per Download and surround them by percentage signs (e.g. "%WF_DIR%").

The real values are substituted at runtime.

Variable NameNotesExample value/Usage
WF_REASON Always FILENEW.
FILENEW
WF_DIR Windows folder synchronized by the current Task.
C:\Sync Me
WF_FILE Complete name of the downloaded file in the Windows folder.
C:\Sync Me\SubDir\NewFile.txt
rem copy the new file
COPY "%WF_FILE%" X:\CopyDir
WF_FILE_D Parent folder of WF_FILE. This always ends with a backslash (\).
C:\Sync Me\SubDir\
WF_FILE_N Name of WF_FILE without the location.
NewFile.txt
rem copy the new file
COPY "%WF_FILE%" "X:\CopyDir\%WF_FILE_N%"
WF_FILE_B Name of WF_FILE without the location and extension.
NewFile
rem copy the new file
COPY "%WF_FILE%" "X:\CopyDir\%WF_FILE_B%.OLD"
WF_FILE_E File extension of WF_FILE, in capital letters without the leading dot ("."). This is empty for a file without an extension.
TXT
rem ignore TXT files before 6 am
IF "%WF_FILE_E%%WF_TIME%" LSS "TXT060000" GOTO :EOF
WF_RELDIR The "relative folder" of WF_FILE starting at the specified Local Windows Folder. This is empty if the file is actually in that folder.
SubDir
rem make sure the same dir exists below X:
MKDIR "X:\%WF_RELDIR%"
rem and copy the new file
COPY "%WF_FILE%" "X:\%WF_RELDIR%"
WF_FILE_SIZE The size in bytes of WF_FILE.
1204
rem do not copy small files
IF %WF_FILE_SIZE% LEQ 1024 GOTO :IgnoreSmall
WF_FILE_SIZE_KB The size in kilobytes of WF_FILE. This is equal to WF_FILE_SIZE divided by 1024, rounded down. This is zero for files smaller than 1024 bytes.
64
rem do not copy files smaller than 1 MB
IF %WF_FILE_SIZE_KB% LEQ 1024 GOTO :IgnoreSmall
WF_FILE_DATE_CR, WF_FILE_TIME_CR These variables contain the creation date (YYYYMMDD) and time (HHMMSS) of WF_FILE.
20070131
REM change the date from YYYYMMDD format REM to MMDDYYYY format SET YYYY=%WF_FILE_DATE_CR:~0,4% SET MM=%WF_FILE_DATE_CR:~4,2% SET DD=%WF_FILE_DATE_CR:~6,2% SET MMDDYYYY=%MM%%DD%%YYYY%
WF_FILE_DATE_LM, WF_FILE_TIME_LM These variables contain the last modified date (YYYYMMDD) and time (HHMMSS) of WF_FILE.
20070131
WF_FILE_SHORTPATH The DOS 8.3 compatible name of WF_FILE.
C:\MONI~001\SUBDIR\NEWF~001.TXT
WF_FILE_SHORTNAME The DOS 8.3 compatible name of WF_FILE without the location.
NEWF~001.TXT
WF_INSTDIR The directory where WatchFTP is installed.
C:\Program Files\WatchFTP
WF_TASKDIR The directory in which your Task information is stored.
C:\UserData\All Users\Application Data\WatchFTP\SyncFTP
WF_CONFIG The name of the Task
SyncFTP
WF_CURRUN Supported in forthcoming versions of WatchFTP.
The "run number" of this Task. This is incremented when WatchFTP is started. The current version of WatchFTP always sets this variable to 1.
WF_CUREVT Supported in forthcoming versions of WatchFTP.
The "file number" of WF_FILE. The first file downloaded by this Task will have a "File Number" of 1. The next file downloaded will have "2". This variable can be used to create unique filenames. The current version of WatchFTP fills this variable with the number of seconds since January 1, 1970 (so you can still use it to create unique filenames).
WF_DATE Current date in the format "YYYYMMDD".
20050714
rem write the event name and file to the log
ECHO %WF_REASON% %WF_FILE% >> C:\logs\log_%WF_DATE%.txt
WF_TIME Current time in the format "HHMMSS" (24 hour clock).
165959
rem write the time and file to the log
ECHO %WF_TIME% %WF_FILE% >> C:\logs\log_%WF_DATE%.txt
WF_DTTM Current date and time in the format "YYYYMMDD HHMMSS" (24 hour clock).
20050714 165959
rem write the timestamp and file to the log
ECHO %WF_DTTM% %WF_FILE% >> C:\logs\log_%WF_DATE%.txt