Tutorial 6 - Move a file from this Path to another Path

This tutorial will implement a JSS process trigger which automatically moves a file from one Path to another Path.

Steps

  1. Open the CompleteFTP Manager and select the Events tab. In the Process Triggers panel click on the Add button to add a new event.

  2. Choose the Upload file event.

  3. Check the "Trigger on success" box, then choose the JSS script and enter the script shown below:

    try {
    	var file = system.getFile(event.virtualPath);
    	file.moveTo("/home/user2");  
    } catch (e) {
        throw "Error while uploading file.";
    }
    

    This script will move myfile.txt from its current path (in this case is /home/user1) to /home/user2.

    The process trigger should now look like this:

  4. When you've done with scripting, click on 'Apply Changes' to save it and you can then start using this event.

Testing your process trigger

Now your new JSS process trigger is ready to use. Let's check it using Filezilla. If you're new to Filezilla, please check the 'how to use Filezilla' Guide here.

  1. Open Filezilla and connect to the server as 'user1'.

  2. Upload a file to server, it will be upload to /home/user1, then our process trigger is triggered and move the file to /home/user2

  3. Now log into the server, with the 'user2' which was used in the second path.

  4. The file myfile.txt should be moved there: