SoFunction
Updated on 2025-04-08

Batch bat download files in a directory on the FTP server

This code takes downloading all files in a directory on the FTP server as an example.

If you need to download all files of type .txt in a certain directory, please put

mget *.*
Change to
mget *.txt

If you need to download a file in a certain directory, please put it in
mget *.*
Change to
get

@echo off
rem SpecifyFTPusername
set ftpUser=FTPUSERNAME
rem SpecifyFTPpassword
set ftpPass=FTPPASSWORD
rem SpecifyFTPServer address
set ftpIP=192.168.0.2
rem Specify待下载的文件位于FTPWhich directory of the server
set ftpFolder=/SharedFile/Log
rem Specify从FTPWhich directory should I store the downloaded files in this machine?
set LocalFolder=C:/temp

set ftpFile=%temp%/
>"%ftpFile%" (
  echo,%ftpUser%
  echo,%ftpPass%
  echo cd "%ftpFolder%"
  echo lcd "%LocalFolder%"
  echo bin
  echo mget *.*
  echo bye
)
start ftp -v -i -s:"%ftpFile%" %ftpIP%