RenameFolder Method
Renames a folder.
Syntax
int RenameFolder(const QString& qsFolderName, const QString& qsNewName);
Remarks
This method renames the folder named FolderName to the name NewName. If NewName is already in use by existing folders, it will be overwritten if the current bucket has versioning enabled, or if the OverwriteOnRename configuration setting is set to true (default).
Since "folders" are in fact just name prefixes formatted to mimic a traditional file system, this method can rename multiple levels of "folders" at once by renaming a prefix. For example, assume you have the following objects in a bucket:
- /pictures/animals/cats/cat1.jpg
- /pictures/animals/cats/cat2.jpg
- /pictures/animals/cats/cat3.jpg
- /pictures/animals/cats/cat4.jpg
- /pictures/animals/dogs/dog4.jpg
- /pictures/animals/dogs/dog5.jpg
Doing the following command would leave you with the following objects in the bucket:
wasabi.RenameFolder("/pictures/animals/cats/", "pictures/pets/dogs");
- /pictures/pets/dogs/cat1.jpg
- /pictures/pets/dogs/cat2.jpg
- /pictures/pets/dogs/cat3.jpg
- /pictures/pets/dogs/cat4.jpg
- /pictures/pets/dogs/dog4.jpg
- /pictures/pets/dogs/dog5.jpg
And doing this command instead would leave you with these objects in the bucket, since the prefix being renamed now includes part of the "filename", and since (by default) the original "dog4.jpg" will get overwritten when "cat4.jpg" is renamed:
wasabi.RenameFolder("/pictures/animals/cats/cat", "pictures/pets/dogs/dog");
- /pictures/pets/dogs/dog1.jpg
- /pictures/pets/dogs/dog2.jpg
- /pictures/pets/dogs/dog3.jpg
- /pictures/pets/dogs/dog4.jpg
- /pictures/pets/dogs/dog5.jpg
Error Handling
This method returns a result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message. (Note: This method's result code can also be obtained by calling the GetLastErrorCode() method after it returns.)