watchDirectory Help > Plugins > Automatically Upload files to an FTP server > Sending RAW FTP commands
Sending RAW FTP commands to your FTP Server
The FTP plugin can send arbitrary commands to your FTP server after it has uploaded your file. This allows you to do special "post processing", doing things that are not directly supported by the FTP plugin.
Creating a file with FTP commands
The FTP plugin will try to process the file named after.filenew or after.filechng when it has uploaded
a new or changed file to your FTP server. These files must be plain text, and located inside your task directory:
C:\Documents and Settings\All Users\Application Data\watchDirectory\<your taskname>
Inside this file you can enter "raw ftp commands" that are understood by your FTP server. You can also use the following 2 variables:
%filepath% - This will contain the complete path of the uploaded file, for example /public_ftp/incoming/newfile.txt
%filename% - This will contain the filename of the uploaded file, without the path (newfile.txt).
As the FTP plugin has no way of knowing what your commands purpose is, it will silently ignore any responses from your FTP server.
An example
Suppose you want to move the uploaded file to another directory with the same name as that file, and always name it hello.txt.
Create the file after.filenew and enter the following commands inside it:
mkd /public_ftp/incoming/testcmd mkd /public_ftp/incoming/testcmd/%filename% RNFR %filepath% RNTO /public_ftp/incoming/testcmd/%filename%/hello.txt
The above script will first create the directory /public_ftp/incoming/testcmd (assuming /public_ftp/incoming already exists), and then
a directory %filename% - %filename% will be replaced by the name (without path) of the new file.
Then it issues a rename command, by sending a RNFR (rename from) and RNTO (rename to). The RNFR uses the %filepath% variable that
will be replaced by the complete pathname of the uploaded file. The RNTO command will send the new filename (and location) of the file.