RENAME — Rename files and directories

Synopsis

RENAME [/?] [/A[+|-]drash] [/S[+|-]drash] [/NEW] [/OLDSRCDIR[+|-]] [/OLDDESTDIR[+|-]] [/E/N/Q/U[+|-]] FilespecsFilespec

Options

/?
Display command syntax information.
/A
Select files by attribute.
/S
Recurse into subdirectories.
/E
Do not display non-fatal error messages.
/N
Simulate execution.
/U
Do not display summary information.
/Q
Operate quietly.
/NEW
Only rename if the target does not exist
/OLDSRCDIR
Duplicate quirks of the 16-bit CMD supplied with IBM OS/2 with respect to source names.
/OLDDESTDIR
Duplicate quirks of the 16-bit CMD supplied with IBM OS/2 with respect to the target name.

Description

The RENAME command first processes the contents of the CMD_RENAME_INIT environment variable, if it has inherited one, as if it were a command tail, before processing any of the command tails that have been passed to it. This allows one to modify default options globally. (One can use command aliases or wrapper scripts to achieve the same effect.)

The RENAME command renames all files that match the first to the penultimate filespecs, which are search wildcard specifications, to new names determined by the final filespec, the target filespec, which is a substitution wildcard specification,.

Each source file is renamed to the directory given in the target filespec (or a subdirectory thereof if the /S option is used). For this to succeed, the source and target directories must reside on the same volume.

Note: This is different to the 16-bit CMD supplied with IBM OS/2, which preserves the original directory of each source file when renaming it if the target substitution wildcard specification does not contain a directory or a drive letter.

As well as renaming files, the RENAME command will rename any subdirectories that happen to match any of the source filespecs. This is the logical behaviour. To prevent this from happening, use the /A-D option to exclude directories from processing, just as for any other command.

Note: This is different to the 16-bit CMD supplied with IBM OS/2. The RENAME command built in to the 16-bit CMD supplied with IBM OS/2 renames subdirectories only if the wildcard specification happens to be the name of an existing directory (not simply if it happens to match that name). This means that the behaviour is dependent from what files and directories happen to exist at the time that the command is run. Without context, one cannot say exactly what the RENAME command will do.

COPYPLUS COPYSTD MORE MOVE DEL DESCRIBE TRUENAME TYPE


The 32-bit Command Interpreter is © Copyright Jonathan de Boyne Pollard. "Moral" rights are asserted.