Rename()
ts
Rename(source: string, target: string): respBase;Renames or moves a file-system object (file or directory) within the same VFS.
IMPORTANT
Rename() can only rename or move files and directories within the same VFS. To move files across different VFSs, use MoveToVFS(). All directories in the target path must already exist, or the function will fail.
Parameters
| Parameter | Type | Explanation |
|---|---|---|
source | string | The fully qualified root-based path to the file/directory you wish to rename |
target | string | The fully qualified root-based path to the desired target name and location |
Returns a respBase object.
Example
ts
var vfs = GetCurrentVFS();
if (vfs != null) {
var resp = vfs.Rename("/data/backup.zip", "/data/old/bkup.zip");
if (resp.Ok()) {
Log("File renamed and/or moved");
} else {
Log("Error: " + resp.ErrorMsg());
}
} else {
Log("VFS was null");
}