How To Transfer Files From An FTP Server Automatically On A Predefined Schedule Using Windows Task Scheduler.
Whether it’s business-to-business file transfer, or peer-to-peer file sharing an FTP server fascilitates fast and secure file transfer for businesses big and small. However configuring an automated and reliable way to transfer files from an FTP server to an FTP client can be challenging or costly as you have to either purchased a managed FTP solution or higher an knowledgable IT professional to set it up for you. In this tutorial we’ll show you how to setup a simple way to transfer files from an FTP Server automatically or on an predefined schedule using the Windows task scheduler. All you’ll need is access to any type of FTP Server and a Windows computer as the FTP client.
In order to complete this tutorial successfully the following items are required. Please ensure to have these items available before taking implementation action on this tutorial:
1) An FTP Server such as the Windows FTP Server feature, Solarwinds Serv-U FTP Server, Filezilla FTP Server, etc
2) A Windows 7 , 8 . 10 or Windows Server 2008 and up (FTP CLIENT)
3) Windows Permissions to run batch files
4) Notepad or any other basic text editor.
1) Open a text editor such as notepad and write FTP commands to connect to an FTP server and copy files using the mget FTP command
2) Create a new windows batch file and set it to use the text file to run FTP commands
3) Open the Windows task scheduler and create a basic task that will open and run the windows batch file.
4) Set the basic task to run repeatedly / automatically.
Automatic File Transfer Setup
The diagram on the right illustrates how the files between the FTP server and the FTP client will be transferred in an automatic manner. The FTP client connects to the FTP server every 5 minutes to upload or download files from the FTP server using an FTP batch file and the windows task scheduler.
Step 1: Create A Simple Text File And Write Ftp Commands To Send Or Receive Files
1) On the Windows FTP Client computer go to the documents folder or any other folder on your computer and create a text file named ftpcommands.txt
Type the following commands in the text file. Be sure not to put any unnecessary spaces or line breaks on the text that you type in:
Click on FILE > SAVE. You can add or remove any FTP command depending on what /how you would like to send or receive files from the the FTP. Click HERE to learn more about FTP commands and what they mean and can do
2) Open a new notepad window and type they following commands :
Click on FILE > SAVE AS, type in any name you would like and place a .bat file extension. Make sure that yo save the batch file in the same folder as the text file with the FTP commands i.e ftpcommands.txt
The -s flag on the FTP command instructs FTP to run the commands that are in the specified file i.e when the batch file is executed it will read the contents of the ftpcommands.txt file and execute them in the order that they are written in.
Step 2: Create The Task To Automate File Transfers Using Task Scheduler.
3) Now that the ftp batch file and the text file containing FTP commands has been created, the next step is to create a Windows task that will automatically run the batch file on a regularly basis thereby automating FTP file transfers.
Click on START > CONTROL PANEL >ADMINISTRATIVE TOOLS > TASK SCHEDULER.
4) Right click on TASK SCHEDULER LIBRARY and click on CREATE NEW FOLDER. Type in a descriptive name for the folder such as MYCUSTOMTASK’S and click on OK.
5) Right click on the new folder and click on CREATE BASIC TASK. Type in a name and the description for the new task and click on NEXT. On the TASK TRIGGER page click on the DAILY option and click on NEXT
6) Select a start date, start time and set the RECUR EVERY option to 1 DAY. Click on NEXT to proceed.
7) Select the “START A PROGRAM” option, click on NEXT and on the PROGRAM / SCRIPT file selection box, use the BROWSE button to select the FTP batch file and click on NEXT.
On the SUMMARY page, click on the check box that says “OPEN THE PROPERTIES DIALOG FOR THIS TASK WHEN I CLICK FINISH” and click on FINISH.
8) On the properties window for the newly created task, click on the GENERAL tab and click on the “RUN WHETHER USER IS LOGGED ON OR NOT” radio button.
9) Click on the TRIGGERS tab, click on the DAILY trigger and click on EDIT. On the ADVANCED SETTINGS section, click on the REPEAT TASK EVERY:” check box and select a suitable time such as 10 minutes.
Set the “FOR A DURATION OF:” option to INDEFINATELY, click on the ENABLED check box then click on OK.
10) Lastly, click on the CONDITIONS tab and uncheck the “START THE TASK IF THE COMPUTER IS ON AC POWER” check box. Click on the “WAKE THE COMPUTER TO RUN THIS TASK” check box and click on OK.