2010-05-19 273 views

回答

6

下面是如何自动内置ftp.exe工具的例子:

的例子是有关上传的,但原理是一样的(只是用get代替put)。

不过,由于这只是“管道命令”到ftp.exe中,我建议不要这样做生产质量的批处理文件(没有错误处理等),而是使用一些外部工具。我仅仅提供了这个答案,因为你明确要求只使用Windows内置命令的解决方案。

编辑:这里有一个具体的例子:

REM replace this with your user name and password 
REM make sure there is no space between the pwd and the >> 

echo user me > getftp.dat 
echo mypass>> getftp.dat 

echo binary >> getftp.dat 

REM replace this with the remote dir (or remove, if not required) 

echo cd remoteSubDir >> getftp.dat 

REM replace this with the local dir 

echo lcd C:\Users\UserName\SomeLocalSubDir >> getftp.dat 

REM replace this with the file name 

echo get file.file >> getftp.dat 
echo quit >> getftp.dat 

REM replace this with the server name 

ftp -n -s:getftp.dat example.com 

del getftp.dat 
+0

所以......篦如何替换现有文件与recived文件?你可以添加代码示例吗? – Rella 2010-05-19 16:02:55

+0

增加了一个例子。 – Heinzi 2010-05-19 17:01:21

+0

我处于这种情况,我需要将文件从FTP路径复制到本机中的本地文件夹。我如何使用批处理文件来实现这一目标。 – 2015-05-12 14:09:29

1

您使用的是什么FTP客户端软件?它是否可以编写脚本?如果是这样,请创建一个脚本来下载文件并从批处理文件中调用此脚本。

我正在做这与WS_FTP。

1

的命令行的内置于大多数Windows操作系统is scriptable FTP程序。你只需要创建一个命令的文本文件,如果你用手运行它(每行一个命令),你会送,然后像这样执行:

ftp -s:download.scr 
+0

那么... grate如何用recived文件替换现有文件?你可以添加代码示例吗? – Rella 2010-05-19 15:56:10

+0

Heinzi的示例代码应该工作:) – ewall 2010-05-19 17:43:42

相关问题