Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typo3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Windows 如何使用具有文件名列表作为输入的txt文件从FTP服务器下载这些文件?_Windows_Batch File_Cmd_Ftp - Fatal编程技术网

Windows 如何使用具有文件名列表作为输入的txt文件从FTP服务器下载这些文件?

Windows 如何使用具有文件名列表作为输入的txt文件从FTP服务器下载这些文件?,windows,batch-file,cmd,ftp,Windows,Batch File,Cmd,Ftp,我有一个连接到FTP服务器的基本批处理文件,并将所有csv文件的列表作为txt文件保存在笔记本电脑上。 稍后,我将要下载该列表上的所有文件(使用txt文件的每一行作为批处理文件的输入),并将FTP服务器上的每个文件“移动”到FTP服务器上的不同文件夹 List.txt包含: A.csv B.csv C.csv etc... 批处理文件使用List.txt作为输入: 连接到FTP服务器 然后对于List.txt的每一行 获取文件名 REN filename/otherfolder/fil

我有一个连接到FTP服务器的基本批处理文件,并将所有csv文件的列表作为txt文件保存在笔记本电脑上。
稍后,我将要下载该列表上的所有文件(使用txt文件的每一行作为批处理文件的输入),并将FTP服务器上的每个文件“移动”到FTP服务器上的不同文件夹

List.txt
包含:

 A.csv
 B.csv
 C.csv
 etc...
批处理文件使用
List.txt
作为输入:

  • 连接到FTP服务器
  • 然后对于List.txt的每一行
  • 获取文件名
  • REN filename/otherfolder/filename
  • 关闭连接
  • 我可以连接到FTP服务器,但当我尝试在批处理中使用
    for/f%%I
    时,它会在FTP外壳之外执行

    Open example.com
    user
    password
    binary
    for /f %%i in "List.txt" do get %%i
    disconnect
    bye
    
    @echo关闭
    rem制作ftp脚本
    (
    EchoOpenExample.com
    回声用户
    回显密码
    回音二进制
    )>ftp.txt
    对于/f“delims=“%%i in(List.txt)do echo get%%i>>ftp.txt
    (
    回音断开
    回音再见
    )>>ftp.txt
    rem连接到ftp
    ftp-s:ftp.txt
    
    编辑:
    你必须阅读的资源

    样本:

    !     Runs the specified command on the local computer.  
    ?     Displays descriptions for Ftp commands. ? is identical to help .  
    Mget  Copies multiple remote files to the local host using the current file transfer type.
    
    @echo关闭
    rem制作ftp脚本
    (
    EchoOpenExample.com
    回声用户
    回显密码
    回音二进制
    )>ftp.txt
    对于/f“delims=“%%i in(List.txt)do echo get%%i>>ftp.txt
    (
    回音断开
    回音再见
    )>>ftp.txt
    rem连接到ftp
    ftp-s:ftp.txt
    
    编辑:
    你必须阅读的资源

    样本:

    !     Runs the specified command on the local computer.  
    ?     Displays descriptions for Ftp commands. ? is identical to help .  
    Mget  Copies multiple remote files to the local host using the current file transfer type.
    

    多亏了保罗的回答,我意识到了我的问题。这就是我所做的:

    @echo off
    REM Enter the username
    echo user USERNAME> ftpcmd.dat
    
    REM Enter the password
    echo PASSWORD>> ftpcmd.dat
    
    REM Change the local computers' directory
    echo lcd D:\LocalFolder\>> ftpcmd.dat
    
    REM create the list of commands to download the csv files, and then
    REM 'move' them to the Backup folder
    for /f "usebackq delims=" %%i in ("d:\LocalFolder\List.txt") do (echo get %%i>>ftpcmd.dat) && (echo ren %%i /Backup/%%i>>ftpcmd.dat)
    
    REM Close the connection
    echo quit >> ftpcmd.dat
    
    REM use -d for debugging, -i for preventing user interaction questions
    ftp  -i -n -s:ftpcmd.dat ftp.example.com
    

    多亏了保罗的回答,我意识到了我的问题。这就是我所做的:

    @echo off
    REM Enter the username
    echo user USERNAME> ftpcmd.dat
    
    REM Enter the password
    echo PASSWORD>> ftpcmd.dat
    
    REM Change the local computers' directory
    echo lcd D:\LocalFolder\>> ftpcmd.dat
    
    REM create the list of commands to download the csv files, and then
    REM 'move' them to the Backup folder
    for /f "usebackq delims=" %%i in ("d:\LocalFolder\List.txt") do (echo get %%i>>ftpcmd.dat) && (echo ren %%i /Backup/%%i>>ftpcmd.dat)
    
    REM Close the connection
    echo quit >> ftpcmd.dat
    
    REM use -d for debugging, -i for preventing user interaction questions
    ftp  -i -n -s:ftpcmd.dat ftp.example.com
    

    谢谢你。虽然它不起作用,但它确实告诉我,我在思考如何创建命令列表并将其传递给ftp时存在一个基本缺陷。谢谢你。虽然它不起作用,但它确实告诉我,在思考如何创建命令列表并将其传递给ftp.exe时,我有一个基本缺陷