rename (User view)

Function

The rename command renames a file or a directory.

Format

rename source-filename destination-filename

Parameters

Parameter Description Value
source-filename

Specifies the name of the source file.

The value is a string of case-sensitive characters in the format of [ <drive> ][ path ][ <file-name> ]. An absolute path name is a string of 1 to 255 characters. A relative path name is a string of 1 to 128 characters. Up to 8 levels of directories are supported.

An absolute path is in the format of <drive> [ path ][ <file-name> ], and a relative path is in the format of [ path ][ <file-name> ]. That is, a relative path is the root path of the current working path.

destination-filename

Specifies the name of the destination file.

The value is a string of case-sensitive characters in the format of [ <drive> ][ path ][ <file-name> ]. An absolute path name is a string of 1 to 255 characters. A relative path name is a string of 1 to 128

characters. Up to 8 levels of directories are supported.

An absolute path is in the format of <drive> [ path ][ <file-name> ], and a relative path is in the format of [ path ][ <file-name> ]. That is, a relative path is the root path of the current working path.

Views

User view

Default Level

3: Management level

Task Name and Operations

Task Name Operations
rpm execute

Usage Guidelines

Usage Scenario

After renaming, the original file name becomes invalid. This command returns error, if a file exists with the new-name.

You can run the rename command to change the name of a file or a directory.

Configuration Impact

If the destination file name is the same as the name of an existing directory or an existing file, the system prompts an error message.

If an absolute path is used, the source and destination paths must be the same.

Example

# Rename the file sample.txt as sample.bak.
<HUAWEI> rename sample.txt sample.bak
Info: Rename file cfcard:/sample.txt to cfcard:/sample.bak ?[Y/N] : y
Info: Renaming file cfcard:/sample.txt to cfcard:/sample.bak...Done
# Rename the file in the authorized directory on the SSH server.
<HUAWEI> system-view
[~HUAWEI] sftp 10.164.39.222
Trying 10.164.39.222 ...
Press CTRL+K to abort
Connected to 10.164.39.222 ...
Please input the username: client001
Enter password:   
sftp-client> rename /test.txt /testnew.txt
Warning: Rename /test.txt to /testnew.txt?[Y/N]: y
Info: Succeeded in renaming file.
Copyright © Huawei Technologies Co., Ltd.
Copyright © Huawei Technologies Co., Ltd.
< Previous topic Next topic >