View Single Post
Old 05-14-2009, 03:36 AM   #3 (permalink)
TheOutcaste
TSF Enthusiast
 
TheOutcaste's Avatar
 
Join Date: Mar 2009
Location: Portland, OR
Posts: 826
OS: MS-Dos 6.22 - Win7


Re: Batch Script to FTP

Welcome to TSF!

This will upload all files in the specified local folder (_lcd variable) to the specified folder on the FTP server (_FTPRoot variable). It doesn't create a file list, just uploads everything.
You do have to create the script file. Note that the username and password are stored in the file, so anyone with read access to the folder that contains the batch file can see the username and password. You can always prompt for the UN/PW when the batch file is run if needed.
Edit the server name, username, and password as needed
Specify the Local folder and the FTP Server folder as needed

Code:
@echo off
SetLocal
:: Set local folder you want to upload here.
Set _lcd=C:\Folder to upload
:: Will use current folder as a Temp folder for the FTP Script
Set _tmpfld=%~dp0
Set _tmpfld=%_tmpfld:~0,-1%
:: Set the Folder on the FTP server that you want to upload to
Set _FTPRoot=/
 >"%_tmpfld%\ftpcmds.}t{" Echo open ftp.server.com
>>"%_tmpfld%\ftpcmds.}t{" Echo Username
>>"%_tmpfld%\ftpcmds.}t{" Echo password
>>"%_tmpfld%\ftpcmds.}t{" Echo cd "%_FTPRoot%"
>>"%_tmpfld%\ftpcmds.}t{" Echo lcd "%_lcd%"
>>"%_tmpfld%\ftpcmds.}t{" Echo binary
>>"%_tmpfld%\ftpcmds.}t{" Echo mput *.*
>>"%_tmpfld%\ftpcmds.}t{" Echo quit
ftp -v -i -s:"%_tmpfld%\ftpcmds.}t{"
:: Delete the script
Del "%_tmpfld%\ftpcmds.}t{"
EndLocal
HTH

Jerry
__________________
Microsoft MVP - Windows Desktop Experience
Of course I know all the answers; I just don't always match the answers to the right questions.
Rated R for Violence -- When your PC flies through a window, that's violent, right?
TheOutcaste is offline   Reply With Quote