How do I download and save multiple files from google drive to a particular folder on my laptop?

I'm following the instructions in this post to download 2 csv files from my google drive to my computer. Here is the code provided -

library(googledrive)
library(purrr)

## store the URL you have
folder_url <- "https://drive.google.com/drive/folders/0B7tJg2i5HAo2c0VzVFVhLUdQcnM"

## identify this folder on Drive
## let googledrive know this is a file ID or URL, as opposed to file name
folder <- drive_get(as_id(folder_url))

## identify the csv files in that folder
csv_files <- drive_ls(folder, type = "csv")

## download them
walk(csv_files$id, ~ drive_download(as_id(.x)))

The instructions download the csv files to my "documents" folder. I am trying to download the files to a particular folder on my laptop using a slight modification to the last bit of code -

walk(csv_files$id, ~ drive_download(as_id(.x),
                                    path = "../Desktop/data_folder/,
                                    overwrite = TRUE))

Unfortunately, this is saving a single .xlsx file which does not contain any data and cannot be opened. How do I correct the code to save both files to a particular folder?

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.