FTP批量下载

DownLoadLog.bat文件:

cd /d D:\VB_Transfer_Log
ftp -s:commands.ini Host

commands.ini文件:

用户名
密码
prompt  #去除确认框
mget *.txt
quit

微软的参考资料:

Ftp

Transfers files to and from a computer running a File Transfer Protocol (FTP) server service such as Internet Information Services. Ftp can be used interactively or in batch mode by processing ASCII text files.

Syntax

ftp [-v] [-d] [-i] [-n] [-g] [-s:FileName] [-a] [-w:WindowSize] [-A] [Host]

Top of page

Parameters

-v : Suppresses the display of FTP server responses.

-d : Enables debugging, displaying all commands passed between the FTP client and FTP server.

-i : Disables interactive prompting during multiple file transfers.

-n : Suppresses the ability to log on automatically when the initial connection is made.

-g : Disables file name globbing. Glob permits the use of the asterisk (*) and question mark (?) as wildcard characters in local file and path names. For more information, see Ftp: Glob

-s: FileName : Specifies a text file that contains ftp commands. These commands run automatically after ftp starts. This parameter allows no spaces. Use this parameter instead of redirection (<).

-a : Specifies that any local interface can be used when binding the FTP data connection.

-w: WindowSize : Specifies the size of the transfer buffer. The default window size is 4096 bytes.

-A : Logs onto the FTP server as anonymous.

Host : Specifies the computer name, IP address, or IPv6 address of the FTP server to which to connect. The host name or address, if specified, must be the last parameter on the line.

/? : Displays help at the command prompt.

Top of page

Remarks
  • You must prefix ftp parameters with a hyphen (-) rather than a slash (/).

  • Ftp command-line parameters are case-sensitive.

  • This command is available only if the Internet Protocol (TCP/IP) protocol is installed as a component in the properties of a network adapter in Network Connections

  • Ftp can be used interactively. After it is started, ftp creates a subenvironment in which you can use ftp commands. You can return to the command prompt by typing the quit command. When the ftp subenvironment is running, it is indicated by the ftp > command prompt.

  • For more information about ftp subcommands, see Related Topics.

  • Ftp supports the use of IPv6 when the IPv6 protocol is installed. For more information, see IP version 6 and IPv6 applications

Top of page

Examples

To log on to the FTP server named ftp.example.microsoft.com, type the following command:

ftp ftp.example.microsoft.com

To anonymously log on to the FTP server named ftp.example.microsoft.com, type the following command:

ftp -A ftp.example.microsoft.com

To log on to the FTP server named ftp.example.microsoft.com and run the ftp commands contained in a file named Resynch.txt, type the following command:

ftp -s:resynch.txt ftp.example.microsoft.com

Top of page

Formatting legend

Format

Meaning

Italic

Information that the user must supply

Bold

Elements that the user must type exactly as shown

Ellipsis (...)

Parameter that can be repeated several times in a command line

Between brackets ([])

Optional items

Between braces ({}); choices separated by pipe (|). Example: {even|odd}

Set of choices from which the user must choose only one

Courier font

Code or program output

Ftp subcommands

Command-line reference A-Z

转载于:https://www.cnblogs.com/jybuding/archive/2009/10/14/1583081.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要使用Java实现FTP批量下载文件,可以使用Apache的Commons Net库来简化FTP操作。以下是一个使用Java实现的简单示例: 首先,需要在项目中导入Apache Commons Net库的依赖,例如使用Maven: ``` <dependency> <groupId>commons-net</groupId> <artifactId>commons-net</artifactId> <version>3.7.2</version> </dependency> ``` 然后,可以创建一个FTP下载器的类来实现批量下载文件的功能。示例代码如下: ```java import org.apache.commons.net.ftp.FTP; import org.apache.commons.net.ftp.FTPClient; import java.io.FileOutputStream; import java.io.IOException; public class FTPDownloader { private static final String SERVER = "ftp.example.com"; private static final int PORT = 21; private static final String USERNAME = "username"; private static final String PASSWORD = "password"; public static void main(String[] args) { FTPClient ftpClient = new FTPClient(); try { ftpClient.connect(SERVER, PORT); ftpClient.login(USERNAME, PASSWORD); ftpClient.setFileTransferMode(FTP.BINARY_FILE_TYPE); ftpClient.enterLocalPassiveMode(); ftpClient.setFileType(FTP.BINARY_FILE_TYPE); ftpClient.changeWorkingDirectory("/path/to/remote/directory"); String[] fileNames = ftpClient.listNames(); for (String fileName : fileNames) { if (fileName.endsWith(".txt")) { FileOutputStream outputStream = new FileOutputStream("download/" + fileName); ftpClient.retrieveFile(fileName, outputStream); outputStream.close(); } } ftpClient.logout(); ftpClient.disconnect(); } catch (IOException e) { e.printStackTrace(); } } } ``` 在上述代码中,我们首先创建了一个`FTPClient`对象,并连接到指定的FTP服务器。然后,我们使用登录凭据进行身份验证。 接下来,我们设置FTP客户端的传输模式和文件类型为二进制。我们还设置了被动模式,以避免由于防火墙等原因导致的连接问题。 然后,我们切换到FTP服务器上指定的远程目录,并获取该目录中的所有文件名列表。 最后,我们遍历文件名列表,检查文件扩展名,如果文件扩展名为`.txt`,则将其下载到本地目录`download/`中。 最后,我们断开与FTP服务器的连接。 请注意,上述代码仅提供一个简单的示例,并未处理所有可能出现的异常情况。在实际应用中,您可能需要进一步完善代码,以处理可能的错误和异常情况。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值