r4ds / mentordash

Other
9 stars 4 forks source link

Question from arati krishnamoorthy (U0266JVP0HF) #88

Open jonthegeek opened 8 months ago

jonthegeek commented 8 months ago

Hi all, I have 2 questions i could use some help with. The first one is how do I go about reading from a google drive that has multiple layers of nested folders. I want a script that looks at all the folders/subfolders and downloads all the .docx files that follow a certain name format. Is there a package that can iterate through folders/subfolders on a google drive?

jonthegeek commented 8 months ago

Reply from Priyanka (UL0BK1MUY)

I think you are looking for purrr pkg.

jonthegeek commented 8 months ago

Reply from Marc-Aurèle Rivière (U03UL96V2G7)

A combination of the googledrive and purrr packages should do the trick:

dest_folder <- here::here("data", "drive") |> fs::dir_create()
drive_find(pattern = ".*.docx", type = drive_mime_type("docx")) |> 
  pwalk(\(name, id, drive_resource) drive_download(as_id(id), path = here(dest_folder, name), overwrite  = TRUE))
jonthegeek commented 8 months ago

Reply from arati krishnamoorthy (U0266JVP0HF)

thank you i will play around with this