Linux mren Command
The Linux mren command is used to rename or move MS-DOS files or directories.
mren is an MS-DOS tool command, similar to the ren command in DOS, which can rename 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 the current drive and current directory.
The new file name is the name of the file to be changed. The new file name cannot have a different drive letter and path than the source file, as this command can only rename files on the same drive.
Syntax
mren [source file or directory...][target file or directory]
Parameter Description:
- [source file or directory...]: The source file name or path to perform the operation on.
Example
To rename the file "autorun.bat" in drive a to "auto.bat" using the mren command, enter the following command:
$ mren a:\autorun.bat auto.bat
# Rename file autorun.bat to auto.bat
Before and after using this command, use the mdir command to view and compare the results as follows:
$ mdir -/ a:\* # View files in drive a
Volume in drive A has no label # Load information
Volume Serial Number is 13D2~055C
Directory for A:\ # Directory information
./TEST <DIR> 2011-08-23 16:59 # File name, directory size, modification time
AUTORUN.BAT 43 2011-08-23 16:56
3 files 308 bytes # Total size
724 325 bytes free # Free space
# Rename file autorun.bat to auto.bat
$ mren a:\autorun.bat auto.bat
$ mdir -/ a:\* # View files in drive a again
Volume in drive A has no label # Load information
Volume Serial Number is 13D2~055C
Directory for A:\ # Directory information
./TEST <DIR> 2011-08-23 16:59 # File name, directory size, modification time
# File name changed to auto.bat, modification time updated to current system time
AUTO.BAT 43 2011-08-23 16:56
3 files 308 bytes # Total size
724 325 bytes free # Free space