string or range of characters representing the existing file name
string or range of characters representing the target file name
FileException on error.
auto t1 = deleteme, t2 = deleteme~"2"; scope(exit) foreach (t; [t1, t2]) if (t.exists) t.remove(); t1.write("1"); t1.rename(t2); assert(t2.readText == "1"); t1.write("2"); t1.rename(t2); assert(t2.readText == "2");
Rename file from to to, moving it between directories if required. If the target file exists, it is overwritten.
It is not possible to rename a file across different mount points or drives. On POSIX, the operation is atomic. That means, if to already exists there will be no time period during the operation where to is missing. See manpage for rename for more details.