Using the %nextfile, %nextpath, and %nextfolder Variables |
Top Previous Next |
The GETNEXTFILE and GETFILE commands search the current local directory for files with names matching the [ file name ] argument and, if a match is found, they populate the %nextfile internal script variable with the file name and the %nextpath internal script variable with the combined path and file name. If no matching file is found the values of %nextfile and %nextpath are set to empty strings.
The GETNEXTFILE command can also optionally be instructed to return the names of subdirectories along with the names of any other matching files by adding the /incldirs option. In this case, when the name of a subdirectory matches the [ file name ] argument, the directory name is returned in the %nextfolder variable and the value of the %nextfile variable is set to an empty string. When used in this manner the %nextpath variable contains the complete path name of the folder. The /incldirs option behaves differently when used with the GETFILE command.
Consider the following example in which Robo-FTP monitors a folder named c:\File Uploads for the presence of any file with an extension of .upload. When a matching file is found, Robo-FTP opens a Dail-up Networking connection, connects to an FTP site and uploads the file. After sending the file, Robo-FTP disconnects, deletes the local file, and then loops back to search for another file. This type of continuous upload loop is sometimes referred to as a hot send process.
WORKINGDIR "c:\File Uploads" :loop GETNEXTFILE "*.upload" /timeout=0 DIALNET "MyConnection" FTPLOGON "ftp.acme-widget.com" SENDFILE %nextfile FTPLOGOFF DELETE %nextfile GOTO loop
Related Commands: GETNEXTFILE, GETFILE See Also: The "Hot Send" Feature, Using %nextfiledate, %nextfiledatetime, and %nextfiletime, Internal Script Variables |