Automate downloading files from SFTP

psftp your a true treasure

I’ve been struggling lately to find online the right script to help get started with a task I needed to deliver: download a file from a SFTP server in a timely manner (using Windows Task Scheduler). All my searches led me either to FTP download automation scripts (not what I was looking for) or deployments that seemed at that point far to complex.

So… psftp was the chosen tool.


  1. Look for psftp.exe in puttygen’s website.
  2. Once downloaded, copy the file to:

3. In your working directory, say C:\DownloadFTPFiles, create a commands.txt file.

This file will contain the browsing command to the relevent directory inside the FTP server using basic DOS commands, i.e. cd folder1 to browse to folder1 and a get command to download the relevant files to your working directory (-r = recursively):

cd folder1
get -r c:\DownloadFTPFiles\FromFTP

4. The syntax is quite simple including the SFTP server, username, password and the path to the commands.txt file.

psftp -l user1 -pw MyPassword123! -b "C:\DownloadFTPFiles\commands.txt"

5. Give it a try, once confirmed the files downloaded successfully you can embed the syntax above in a batch or PowerShell file and add it to a Scheduled Task.