Search
Plugins > vCenter Server 5.5.3 > VcFileManager > moveDatastoreFile_Task

Method moveDatastoreFile_Task(String sourceName, VcDatacenter sourceDatacenter, String destinationName, VcDatacenter destinationDatacenter, boolean force)

Moves the source file or folder to the destination.

If the destination file does not exist, it is created. If the destination file exists, the force parameter determines whether to overwrite it with the source or not. If the source path is a folder, then the destination path must not exist; the destination cannot be overwritten even with a force flag in that case. Folder moves are recursive, treating all files and disks to move as binary.

If source (or destination) name is specified as a URL, then the corresponding datacenter parameter may be omitted.

If any intermediate level folder specified by the source and destination does not exist, a VcFileNotFound fault is thrown.

If a file of a virtual machine is moved, it may corrupt that virtual machine. If a file of a virtual machine is overwritten on the destination datastore as a result of the force parameter, it may corrupt that virtual machine.

If the source is an extent of a virtual disk, this operation treats the extent as a file.

If source and destination resolve to the same file system location, the call has no effect.

It is important to note that this operation will provide transactional guarantees only for a file. No guarantees are provided for folder moves. If the intent is to move a virtual machine registered in the inventory, with transactional guarantees, please refer to VcVirtualMachine. If the intent is to rename a virtual machine registered in the inventory, please refer to VcManagedEntity.

Datastore.FileManagement privilege is required on both source and destination datastores.

Returns

VcTask

Arguments

Name Type Description
sourceName String The name of the source, either a URL or a datastore path referring to the file or folder to be moved.
sourceDatacenter VcDatacenter If <code>sourceName</code> is a datastore path, the datacenter for that datastore path. Not needed when invoked directly on ESX. If not specified on a call to VirtualCenter, <code>sourceName</code> must be a URL.
destinationName String The name of the destination, either a URL or a datastore path referring to the destination file or folder.
destinationDatacenter VcDatacenter If <code>destinationName</code> is a datastore path, the datacenter for that datastore path. Not needed when invoked directly on ESX. If not specified on a call to VirtualCenter, it is assumed that the destination path belongs to the source datacenter.
force boolean If true, overwrite any identically named file at the destination. If not specified, it is assumed to be false.