Created
August 5, 2019 13:50
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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