gpt4 book ai didi

windows - 如何创建 .BAT 文件以从 HTTP\ftp 服务器下载文件?

转载 作者:可可西里 更新时间:2023-11-01 13:22:22 24 4
gpt4 key购买 nike

如何创建一个.BAT文件来从FTP服务器下载文件或文件夹? (并用它替换现有文件)(我们有像 ftp://me:mypass@example.com/file.file (或 http://example.com/file.file )这样的链接和像 C 这样的绝对文件链接:\Users\UserName\Some mixed Русский English Adress\file.file)(仅使用原生windows(xp vista win7等)BAT函数和文件)

最佳答案

下面是一个如何自动执行内置 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

关于windows - 如何创建 .BAT 文件以从 HTTP\ftp 服务器下载文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2866787/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com