# NOT RUN {
## Create a file to rename
file <- drive_create("file-to-rename")
## Rename it
file <- drive_rename(file, name = "renamed-file")
## `overwrite = FALSE` errors if something already exists at target filepath
## THIS WILL ERROR!
drive_create("name-squatter")
drive_rename(file, name = "name-squatter", overwrite = FALSE)
## `overwrite = TRUE` moves the existing item to trash, then proceeds
file <- drive_rename(file, name = "name-squatter", overwrite = TRUE)
## Clean up
drive_rm(file)
# }
Run the code above in your browser using DataLab