Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/3.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_File_Ftp_Move - Fatal编程技术网

脚本Windows FTP移动和重命名文件

脚本Windows FTP移动和重命名文件,windows,file,ftp,move,Windows,File,Ftp,Move,基本上我的公司FTP上有2个文件,我需要用户能够在需要时单击脚本来交换这2个文件 FTP树如下所示: /file1.vxml /swap/file1.vxml 在这里,我需要连接到我的ftp(在Windows上),在移动之前将/file1.vxml重命名为/file2.vxml,然后将其移动到/swap/(不覆盖/swap/file1.vxml)。然后在/swap/file2.vxml上执行相反的操作,并将其移动到根目录 我已经有了连接: open host.myhost.com user m

基本上我的公司FTP上有2个文件,我需要用户能够在需要时单击脚本来交换这2个文件

FTP树如下所示:

/file1.vxml
/swap/file1.vxml
在这里,我需要连接到我的ftp(在Windows上),在移动之前将/file1.vxml重命名为/file2.vxml,然后将其移动到/swap/(不覆盖/swap/file1.vxml)。然后在/swap/file2.vxml上执行相反的操作,并将其移动到根目录

我已经有了连接:

open host.myhost.com
user myusername
mypassword
cd /
bye
但是我缺少的是如何正确移动和重命名ftp上的文件。

使用“REN”重命名ftp中的文件

ftp> REN FileA FileB
在FTP中,重命名和移动本质上是相同的,您可以通过重命名将文件移动到不同的文件夹

ftp> REN Here ../There

您可能需要将第一个文件下载回本地服务器以保存副本,然后重命名第二个文件,然后将下载的文件复制回服务器。我不知道有哪个FTP服务器支持在其内部复制文件。

谢谢您的帮助。正如你所建议的,我添加了一行代码来下载该文件,并在重命名后将其上载回。