Simpler Navigation for Servers and Operating Systems
Completed: a much simpler Servers and Operating Systems section of the Community. We combined many of the older boards, so you won't have to click through so many levels to get at the information you need. Check the consolidated boards here as many sub-forums are now single boards.
Operating System - Microsoft
Showing results for 
Search instead for 
Did you mean: 

How to write a batch file for FTP?

Go to solution

How to write a batch file for FTP?

how to write a file that will compress a files in a folder and then will send that compressed file trough FTP software??

@echo off

set /P my_folder="Please enter folder to zip and FTP: "

if exist %my_folder% goto do_zfile
goto error


cd %my_folder%

rem .: if your date has '/' in the date, they need to be stripped out.
for /f "delims='/'" %%i in ('%date%') do
set my_date=%%i-%%j-%%k

zip_program /switches *.*

set /P my_loc="Please enter FTP site: "
set /P my_id="Please enter your ID: "
set /P my_pass="Please enter your Password: "

echo open %my_loc% > ftp_conn.txt
echo user %my_id% %my_pass%>> ftp_conn.txt
echo binary >> ftp_conn.txt
echo hash >> ftp_conn.txt
echo put >> ftp_conn.txt
echo close >> ftp_conn.txt
echo quit >> ftp_conn.txt

ftp -s:ftp_conn.txt

del ftp_conn.txt

goto done

echo Folder was not found.


in that when i'm asked for a folder to zip and ftp i don't know what to write... ???
Jon Finley
Honored Contributor

Re: How to write a batch file for FTP?

When you're asked which folder, enter What-ever folder it is that you need to zip.

Let's say that you are storing files that you want to FTP in a folder named C:\my_ftp

When prompted, you would enter: C:\my_ftp

Also, in the script, you will want to replace "zip_program /switches" with the name of your installed zip program, and the appropriate commandline switches you want to use.

"Do or do not. There is no try!" - Yoda