# NOT RUN {
# create a file to move
file <- drive_example_remote("chicken.txt") %>%
drive_cp("chicken-mv.txt")
# rename it, but leave in current folder (root folder, in this case)
file <- drive_mv(file, "chicken-mv-renamed.txt")
# create a folder to move the file into
folder <- drive_mkdir("mv-folder")
# move the file and rename it again,
# specify destination as a dribble
file <- drive_mv(file, path = folder, name = "chicken-mv-re-renamed.txt")
# verify renamed file is now in the folder
drive_ls(folder)
# move the file back to root folder
file <- drive_mv(file, "~/")
# move it again
# specify destination as path with trailing slash
# to ensure we get a move vs. renaming it to "mv-folder"
file <- drive_mv(file, "mv-folder/")
# `overwrite = FALSE` errors if something already exists at target filepath
# THIS WILL ERROR!
drive_create("name-squatter", path = "~/")
drive_mv(file, path = "~/", name = "name-squatter", overwrite = FALSE)
# `overwrite = TRUE` moves the existing item to trash, then proceeds
drive_mv(file, path = "~/", name = "name-squatter", overwrite = TRUE)
# Clean up
drive_rm(file, folder)
# }
Run the code above in your browser using DataLab