.Bat upload to FTP entire Folder - HELP!

Microsoft Windows xp professional w/serv...
February 1, 2010 at 18:49:05
Specs: Windows XP
This is my code so far:

@Echo Off
Echo *NAME*> ftpcmd.txt
echo *PASSWORD*>> ftpcmd.txt
echo binary>> ftpcmd.txt
echo prompt n>>ftpcmd.txt
echo mget *.html>> ftpcmd.txt
echo bye >> ftpcmd.txt
ftp -s:ftpcmd.txt ftp.drivehq.com
del ftpcmd.txt

I'm trying to get *\My Documents\My Chatlogs\ sent to the FTP, the entire folder with subfolders.

If I use:
echo cd My Documents\My Chatlogs
with
echo mpget *.*
It still doesn't work.

It either will say 'Permission Denied', or it just won't transfer it.

So how can I get a .bat to upload an ENTIRE folder and subfolders to a remote FTP?

Thanks.


See More: .Bat upload to FTP entire Folder - HELP!

Report •


#1
February 1, 2010 at 20:36:48
don't you want "mput" to upload? mget downloads files

Report •

#2
February 2, 2010 at 09:47:29
How can I get .bat to upload to FTP an ENTIRE folder and subfolders?

Report •

#3
February 2, 2010 at 12:03:41
might try this modification ( [ ] are just for reference):
[echo prompt n>>ftpcmd.txt]
for /f "tokens=* delims=" %%a in ('dir /b /s /ad') do echo mput %%a\*.html>> ftpcmd.txt
[echo bye >> ftpcmd.txt]

alot depends on if you want local dir. structure mirrored on remote.


Report •

Related Solutions

#4
February 3, 2010 at 08:23:08
> How can I get .bat to upload to FTP an ENTIRE
> folder and subfolders?
>

The limitation of FTP is that it only transfers files from any given directory (on windows) to another directory (in unix). It does not understand to copy directories ...

It's a great tool, apart from the directory stuff. Graphic versions of FTP overcome this issue, but the (default Windows) FTP command does not understand copying of directories.

Maybe in Windows 7 ?

ps, About the permissions : by default, the FTP tool will set itself in the home directory of the user you are connected with. Usually, but not always, files inside that directory are nicely readable and writable ... (edit : this section refers to the *nix account, of course)


Report •

#5
February 3, 2010 at 08:27:18
> alot depends on if you want local dir. structure
> mirrored on remote.
>

If you don't, you can indeed experience "flattening" of a structure (all files inside a structure, copied to 1 directory, often files overwriting each other ... but in some case no overwrites at all, that depends).

If you want to mirror ... well, good luck. Keep in mind that linux does not like any whitespaces in either files or directories, so you also need to convert that.


Report •

#6
February 3, 2010 at 10:14:23
tvc: Maybe in Windows 7 ?
I'd have to double check when I got home, but I think it has identical functionality. It might even be the same binary.

Report •

#7
February 3, 2010 at 12:02:45
there's a gnu utility call wput, complement of wget.
i downloaded it (free) but have never used it.

Report •

#8
February 3, 2010 at 15:10:24
> I'd have to double check when I got home, but I think it
> has identical functionality. It might even be the same
> binary.
>

I'll be checking some OS as well ... hmmm


Report •

#9
February 4, 2010 at 04:16:31
Unless OP clarifies, not much will get done.


=====================================
Helping others achieve escape felicity

M2


Report •

#10
February 6, 2010 at 09:26:14

How can I get .bat to upload to FTP an ENTIRE folder and subfolders?


Check out http://www.biterscripting.com/helpp... .


That script mirrors an entire local folder from a
local computer to a remote FTP server. Will
create the subfolders as necessary.
Call the script like this from biterscripting.


script "C:/Scripts/SS_FTPUpload.txt" 
  localpath("/website") remotepath("/")
  ftpserver("ftp.server.com") ftplogin("login") ftppassword("pswd")


(Enter the entire command on one line. I had to split it to make it visible.)

"/website"
path to local folder

"/"
path on the FTP server.

"ftp.server.com"
FTP Server

"login"
your login

"pswd"
your password

So, for example, if the local computer has following files,

/mywebsite/index.html
/mywebsite/log.gif
/mywebsite/fruits/apple.html
/mywebsite/fruits/apple.gif
/mywebsite/fruits/addfruit.pl

the FTP server will have the following files.

/index.html
/log.gif
/fruits/apple.html
/fruits/apple.gif
/fruits/addfruit.pl


The folder 'fruits' will be created if it does not exist. Will upload .html and .gif files in correct (ascii, binary) mode.



The script does somethings similar to why2u's script - it creates a file containing commands around the local directory structure. The link has the code for the script, so you can modify.



Report •

#11
February 7, 2010 at 06:31:27
Just wondering, but there MUST be somebody out there, having a Windows EXE with a modified FTP-type of program to be run from command line, which CAN overcome the directory stuff, like the GUI-programs do ...

Report •

#12
February 7, 2010 at 12:21:15
It can be done, sure, but as Window's semi-official scripting language is VBScript, it's much easier to just use a COM based FTP solution.

Report •

#13
February 7, 2010 at 12:28:57
that's what wput does - download a copy:
http://wput.sourceforge.net
http://gnuwin32.sourceforge.net/pac...

and look at the -help. it will build directories as needed, plus a lot of other stuff.


Report •

#14
February 8, 2010 at 04:45:12
There you go ... I'll have a look at this myself ...

Report •


Ask Question