Link to home
Start Free TrialLog in
Avatar of jonnyfb
jonnyfb

asked on

Batch file to upload files to FTP server

I need a batch file that would do this:
(I would normaly do this manually in CMD)

open ftp.***.com

User: ***.com
Password: ***

cd htdocs
lcd C:/mysite

mput * except database

quit
Avatar of Stimphy
Stimphy

In your batch put something like

ftp -s:ftp.txt
exit

The -s Switch stands for Script
this will load the specified script file for your ftp session

In ftp.txt put your code

open ftp.***.com
***.com
***
cd htdocs
lcd C:/mysite
mput * except database
bye
Have you considered trying VBScript to do this?  If you'd like to give it a shot, try this:

Option Explicit
Dim objShell, objShell2
Set objShell = CreateObject("WScript.Shell")

objShell.Run "ftp" 'open FTP
Wscript.Sleep 500 'Pause
objShell.SendKeys "open ftp.**.com {ENTER}" 'Make sure you leave the {ENTER} in there...
objShell.SendKeys "USERNAME {ENTER}" 'FTP login name
objShell.SendKeys "PASSWORD {ENTER}" 'FTP password
objShell.SendKeys "cd htdocs" 'Change dir cmd
objShell.SendKeys "lcd c:\MySite"
objShell.SendKeys "mput * except database"
objShell.SendKeys "quit"
Wscript.Sleep 1000
Avatar of jonnyfb

ASKER

Thankyou Stimphy!

But when I put mput * except database I was wondering if you could explain how to  put all files except ones with the .mdb extention
How many different types of files can exist in this DIR?  My guess is probably not many, so do something like this.

mput *.exe *.zip *.txt

A less efficient way is
mput *
mdelete *.mdb

Regaurds,
Dave
Avatar of jonnyfb

ASKER

I need some way of saying yes when it prompts me with a ? because at the moment it just says:

mput file.htm? mput file.htm? mput file.htm? mput file.htm? mput file.htm? mput file.htm? mput file.htm? mput file.htm? mput file.htm? mput file.htm? mput file.htm? mput file.htm? mput file.htm? mput file.htm? mput file.htm? mput file.htm? mput file.htm? mput file.htm?

But it doesnt actually put the files! How will I overcome this problem?
ASKER CERTIFIED SOLUTION
Avatar of Stimphy
Stimphy

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial