
In computing, rename refers to the altering of a name of a file. This can be done manually by using a shell command such as
ren or
mv, or by using
batch renaming software that can automate the renaming process.
Implementations
The
C standard library
The C standard library, sometimes referred to as libc, is the standard library for the C (programming language), C programming language, as specified in the ISO C standard.International Organization for Standardization, ISO/International Electrote ...
provides a function called ''rename'' which does this action. In
POSIX
The Portable Operating System Interface (POSIX; ) is a family of standards specified by the IEEE Computer Society for maintaining compatibility between operating systems. POSIX defines application programming interfaces (APIs), along with comm ...
, which is extended from the C standard, the ''rename'' function will fail if the old and new names are on different mounted
file systems.
In
SQL
Structured Query Language (SQL) (pronounced ''S-Q-L''; or alternatively as "sequel")
is a domain-specific language used to manage data, especially in a relational database management system (RDBMS). It is particularly useful in handling s ...
, renames are performed by using the
CHANGE
specification in
ALTER TABLE
statements.
Atomic rename
In
POSIX
The Portable Operating System Interface (POSIX; ) is a family of standards specified by the IEEE Computer Society for maintaining compatibility between operating systems. POSIX defines application programming interfaces (APIs), along with comm ...
, a successful call to ''rename'' is guaranteed to have been
atomic from the point of view of the current host (i.e., another program would only see the file with the old name or the file with the new name, not both or neither of them). This aspect is often used during a file save operation to avoid any possibility of the file contents being lost if the save operation is interrupted.
The ''rename'' function from the C library in
Windows
Windows is a Product lining, product line of Proprietary software, proprietary graphical user interface, graphical operating systems developed and marketed by Microsoft. It is grouped into families and subfamilies that cater to particular sec ...
does not implement the POSIX atomic behaviour; instead it fails if the destination file already exists. However, other calls in the
Windows API
The Windows API, informally WinAPI, is the foundational application programming interface (API) that allows a computer program to access the features of the Microsoft Windows operating system in which the program is running. Programs can acces ...
do implement the atomic behaviour.
References
Computing terminology
{{Computing-stub