Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/6.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 FTP';重命名';用于移动匹配通配符的远程文件的命令_Windows_Batch File_Ftp - Fatal编程技术网

Windows FTP';重命名';用于移动匹配通配符的远程文件的命令

Windows FTP';重命名';用于移动匹配通配符的远程文件的命令,windows,batch-file,ftp,Windows,Batch File,Ftp,我正在编写一个*.bat文件(Windows),在该文件中,我使用FTP命令将远程文件恢复到本地计算机上。远程目录包括一个存档子目录,在本地计算机上下载文件后,我想在其中移动这些文件 我的脚本在*.bat文件中: ftp -v -i -s:GET_FILES_FTP.txt open example.com username password lcd S:\ lcd repository/files mget *.txt rename *.txt archive/ disconnect bye

我正在编写一个
*.bat
文件(Windows),在该文件中,我使用FTP命令将远程文件恢复到本地计算机上。远程目录包括一个
存档
子目录,在本地计算机上下载文件后,我想在其中移动这些文件

我的脚本在
*.bat
文件中:

ftp -v -i -s:GET_FILES_FTP.txt
open example.com
username
password
lcd S:\
lcd repository/files
mget *.txt
rename *.txt archive/
disconnect
bye
我在
获取文件\u FTP.txt中的脚本

ftp -v -i -s:GET_FILES_FTP.txt
open example.com
username
password
lcd S:\
lcd repository/files
mget *.txt
rename *.txt archive/
disconnect
bye
请注意,主机名、用户名和密码不是我真正使用的

TXT文件在本地计算机上正确下载

问题是,
rename*.txt archive/
不会被解释,并且文件不会移动到
archive
文件。在命令窗口中,我收到一条错误消息:

找不到目录

我找不到比这更好的额外信息了

知道如何移动文件吗?

Windows的
ftp.exe
不支持通配符

您必须根据下载文件的列表动态生成脚本文件,并为每个文件使用单独的
rename
命令


或者在重命名/移动时使用支持通配符的其他命令行FTP客户端

例如,与批处理文件类似:

winscp.com /log=winscp.log /command ^
    "open ftp://username:password@example.com" ^
    "lcd S:\" ^
    "lcd repository\files" ^
    "get *.txt" ^
    "mv *.txt archive/" ^
    "exit"
详情请参阅:


(我是WinSCP的作者)

谢谢!我会尝试这两种选择,看看它对我有什么作用。“重命名”命令在没有通配符的情况下有效吗?例如,将“files”目录中的所有文件移动到“archive”目录中?如果没有通配符,“rename”命令会起作用吗?不,那也是(某种)通配符。它只能处理特定的文件。