drive_mv | R Documentation |
Move a Drive file to a different folder, give it a different name, or both.
drive_mv(
file,
path = NULL,
name = NULL,
overwrite = NA,
verbose = deprecated()
)
An object of class dribble
, a tibble with one row per file.
Makes a metadata-only request to the files.update
endpoint:
# 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-mv", path = "~/")
drive_mv(file, path = "~/", name = "name-squatter-mv", overwrite = FALSE)
# `overwrite = TRUE` moves the existing item to trash, then proceeds
drive_mv(file, path = "~/", name = "name-squatter-mv", overwrite = TRUE)
# Clean up
drive_rm(file, folder)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.