Table of contents
Introduce the DOS commands used this time
4. Enter username and password
5. View the FTP file directory
10. There will be a prompt when downloading
11. Time-consuming calculations
The purpose of this article is to explain how to directly download files on FTP to a specified local folder through the command line.
The reason for using this method is that in one of the functions that the company needs to implement, files need to be read from FTP, and the cumulative number of FTP files has reached 82 w files, which makes reading very time-consuming. Older files need to be cut to a dedicated server for backup files, and the backed up files should be compressed.
Originally, I wanted to directly connect to the FTP server and cut the files directly, but encountered a series of problems. The first one was that there were too many files, which made it impossible to enter the folder, and the direct display operation timed out, so I considered using the DOS command line to obtain document.
Introduce the DOS commands used this time
1. Open the command line
[win + R → enter cmd → enter]
2. Enter FTP
[Input FTP → Enter], when [ftp>] appears, you have successfully entered ftp
3. Connect to FTP
Suppose the FTP address to be connected is: 130.147.192.xx, the account is ftpuserxxx, and the password is userxxxx
【open 130.147.192.xx】
The default port 21 is used here. If you use other ports, such as port 110, please enter [open 130.147.192.xx 110]
4. Enter username and password
[User name → Enter → Password → Enter], [User logged in, proceed] means success
5. View the FTP file directory
[dir → Enter], it can be seen that there is only one folder of HIS under this directory
6. Enter the [HIS] folder
[cd his → Enter]
7. Specify the local folder
It is necessary to create a folder in advance, which is the storage folder for FTP file download.
【lcd d:\FTPDownLoad → Enter】
8. Switch interactive mode
When the interactive mode is turned off, there will be no prompt when using the mget command in the future
【prompt → Enter】
9. Download files
[mget *.* → press Enter], download the files under the HIS directory on the FTP server to the local [d:\FTPDownLoad]
*.* wildcard, if you need a txt file, just change it to *.txt
After input, the file directory will be obtained. If there are many files, it will stay here for a long time.
10. There will be a prompt when downloading
At this time, check the local [d:\FTPDownLoad] folder, and find that some parts have been downloaded, just wait for the download to complete.
11. Time-consuming calculations
There are 82w files, and each file takes about tens of ms, and it still takes several hours to download all of them.
【820000 * 20 ms / 1000 ms / 60 / 60 = 4.5556 H】
1 s = 1000 ms
1 min = 60 s
1 H = 60 min