如何创建一个.bat文件下载从HTTP文件\\ FTP服务器? [英] How to create a .BAT file to download file from HTTP\ftp server?

查看:3172
本文介绍了如何创建一个.bat文件下载从HTTP文件\\ FTP服务器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何创建一个 .BAT 文件从FTP服务器上下载文件或文件夹? (与它替换现有文件)(我们有像链接的ftp://我:mypass@example.com/file.file (或http://example.com/file.file )等的绝对文件链接C:\\ Users \\用户名\\有些混合Русский英文住址\\的File.File )(仅使用本地的Windows(XP Vista的WIN7等)BAT功能和文件)

How to create a .BAT file to download file or folder from FTP server? (and replace with it existing file) (we have links like ftp://me:mypass@example.com/file.file (or http://example.com/file.file) and absolute file link like C:\Users\UserName\Some mixed Русский English Adress\file.file) (using only native windows (xp vista win7 etc) BAT functions and files)

推荐答案

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

Here is an example of how to automate the built-in ftp.exe tool:

这个例子是关于上传,但原理是一样的(只是使用 GET 而不是)。

The example is about uploading, but the principle is the same (just use get instead of put).

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

Still, since this is just "piping commands" into ftp.exe, I recommend not to do this for production-quality batch files (no error handling, etc.), but to use some external tool instead. I provided this answer only because you explicitly asked for a solution that only uses Windows built-in commands.

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

Here's a concrete example:

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

这篇关于如何创建一个.bat文件下载从HTTP文件\\ FTP服务器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆