rename
重命名 SFTP 或 FTP 服务器上的文件
说明
示例
重命名文件
连接到 FTP 服务器并重命名该服务器上的文件。此示例显示 ftp.example.com
(实际上并不存在的计算机)上的一个假想 FTP 会话。如果您拥有 FTP 服务器帐户,有权在该服务器上上传或更改文件,则可以像本例中一样使用 rename
函数。
首先,连接到服务器。
s = ftp('ftp.example.com')
FTP with properties: Host: "ftp.example.com" Username: "anonymous" Port: 21 ServerLocale: "en_GB" DirParserFcn: @matlab.io.ftp.parseDirListingForUnix Mode: "binary" LocalDataConnectionMethod: "passive" RemoteWorkingDirectory: "/"
显示 FTP 服务器上当前文件夹的内容。
dir(s)
myscript.m README.txt pub
重命名 FTP 服务器上的文件。
rename(s,'README.txt','INTRO.txt')
在 FTP 服务器上显示更新后的内容,包括重命名的文件。
dir(s)
INTRO.txt myscript.m pub
输入参数
s
— 连接到 SFTP 或 FTP 服务器
SFTP 对象 | FTP 对象
与 SFTP 或 FTP 服务器的连接,指定为 SFTP 对象或 FTP 对象。
oldname
— 文件的原始名称
字符向量 | 字符串标量
SFTP 或 FTP 服务器上文件的原始名称,指定为字符向量或字符串标量。
newname
— 文件的新名称
字符向量 | 字符串标量
SFTP 或 FTP 服务器上文件的新名称,指定为字符向量或字符串标量。
提示
rename
函数仅重命名 SFTP 或 FTP 服务器上的文件。要重命名本地计算机上的文件,请使用movefile
函数。
版本历史记录
在 R2006a 之前推出
MATLAB 命令
您点击的链接对应于以下 MATLAB 命令:
请在 MATLAB 命令行窗口中直接输入以执行命令。Web 浏览器不支持 MATLAB 命令。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)