Rename a file or directory
From CodeCodex
[edit] Implementations
#include <stdio.h>
rename("/path/to/old/file", "/path/to/new/file");
// File (or directory) with old name
File file = new File("oldname");
// File (or directory) with new name
File file2 = new File("newname");
// Rename file (or directory)
boolean success = file.renameTo(file2);
if (!success) {
// File was not successfully renamed
}
Sys.rename "/path/to/old/file" "/path/to/new/file"
rename("/path/to/old/file", "/path/to/new/file");
[edit] Python
os.rename("/path/to/old/file", "/path/to/new/file")
begin
File.rename("/path/to/old/file", "/path/to/new/file")
rescue Exception => e
# handle file rename error here
end