Skip to content

Instantly share code, notes, and snippets.

@hemprichbennett
Created August 5, 2019 13:50
Show Gist options
  • Save hemprichbennett/db53d449492d1703e15e4f22b427a599 to your computer and use it in GitHub Desktop.
Save hemprichbennett/db53d449492d1703e15e4f22b427a599 to your computer and use it in GitHub Desktop.
Backs up all documents in your google docs folder to a local directory
library(googledrive)
library(dplyr)
# Make a directory for todays date
date <- as.character(Sys.Date())
# Set the location for where the docs should be saved
outdir <- paste0("~/Dropbox/work/google_docs_backups/", date)
if (!dir.exists(outdir)) {
dir.create(outdir)
}
# Find all documents
docs <- drive_find(type = "document") %>%
mutate(outname = paste(outdir, name, sep = "/"))
# Download them
for (desired_file in 1:nrow(docs)) {
drive_download(
file = as_id(docs$id[desired_file]),
path = docs$outname[desired_file],
overwrite = TRUE
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment