Linux mren command

Linux 命令大全Linux Command Reference

The Linux mren command is used to change the name of MS-DOS files or directories, or to move files or directories.

mren is an MS-DOS utility command, similar to the ren command under DOS, and can change the names of MS-DOS files or directories.

The source file must be an existing file on the disk. If the drive letter and path are omitted, it refers to a file on the current drive and in the current directory.

The new file name is the name to be changed to. The new file name cannot be preceded by a drive letter or path different from the source file, because this command can only change file names on the same drive.

Syntax

mren [源文件或目录...][目标文件或目录]

Parameter description:

  • [Source file or directory...]: The source file name or source file path on which the operation is performed.
  • [Target file or directory]: The target file name or target file path for the operation.

Examples

Use the command mren to change the file name of "autorun.bat" on drive A to "auto.bat". Enter the following command:

$ mren a:\autorun.bat auto.bat  
#将文件autorun.bat重命名为auto.bat  

Before and after using this command, use the mdir command to view and compare. The results are as follows:

$ mdir -/ a:\*                  #查看a盘中的文件  
Volume in drive A has no label  #加载信息  
Volume Serial Number is 13D2~055C  
Directory for A:\                   #以下为目录信息  
./TEST <DIR> 2011-08-23 16:59       #文件名,目录大小,修改时间  
AUTORUN.BAT 43 2011-08-23 16:56  
3 files 308 bytes                   #统计总大小  
724 325 bytes free              #剩余空间  
#将文件autorun.bat重命名为auto.bat  
$ mren a:\autorun.bat auto.bat        
$ mdir -/ a:\*                  #再次查看a盘中文件  
Volume in drive A has no label      #加载信息  
Volume Serial Number is 13D2~055C  
Directory for A:\                   #以下为目录信息  
./TEST <DIR> 2011-08-23 16:59       #文件名目录大小 修改时间  
#文件名被改为auto.bat,修改时间改为当前系统时间  
AUTO.BAT 43 2011-08-23 16:56          
3 files 308 bytes                   #统计总大小  
724 325 bytes free              #剩余空间  

Linux 命令大全Linux Command Reference

Other Extensions