开发者

Upload sub-folders to FTP in Windows command line

I have to upload an entire folder commandline on Windows. I can't 开发者_开发问答get it to upload the subdirectories including it's files.

ftp
open snuzzer.dk
username
password
mput *.*

This only uploads all files in the root.

Can anyone help me?


Windows command-line ftp.exe client does not support operations with (sub)folders.

You have to use a 3rd-party FTP client.


For example with WinSCP you can use:

winscp.com /log=ftp.log /command ^
    "open ftp://username:password@ftp.example.com/" ^
    "put *" ^
    "exit"

There's a guide for converting Windows ftp.exe script to WinSCP script. Though easier is to have WinSCP GUI generate the script or batch file for you.

(I'm the author of WinSCP)


one way would be to use ncftpput with the -R option.


You could use a batch script that creates a command file for ftp and then issues the ftp command with that file.

Something liek this:

@ECHO OFF    
ECHO open snuzzer.dk>command.txt
ECHO username>>command.txt
ECHO password>>command.txt

FOR /F "delims=" %%A IN ('DIR /b /s /a-d "%1"') DO (
   ECHO put "%%A">>command.txt
)

ECHO close>>command.txt

ftp /s:command.txt

The FOR loop simply creates a list of all files recusively.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜