Skip to contents

Downloads all files or filtered files from a public Google Drive folder to a local directory.

Usage

download_google_drive(url, path = NULL, title = NULL)

Arguments

url

Character string. The Google Drive folder URL from which to download files. The function will extract the folder ID from standard Google Drive folder URLs.

path

Character string or NULL. The local directory path where files should be downloaded. If NULL (default), files are downloaded to the current working directory. The function will create the directory if it doesn't exist.

title

Character vector or NULL. Patterns to match against file names for filtering. If provided, only files whose names contain any of these patterns will be downloaded. Pattern matching is case-insensitive. If NULL (default), all files are downloaded.

Value

Character string. The path to the directory where files were downloaded.

Examples

if (FALSE) { # \dontrun{
# Download all files from a Google Drive folder to current directory
download_google_drive("https://drive.google.com/drive/folders/1Rgxfiw")

# Download to a specific directory
download_google_drive(
  url = "https://drive.google.com/drive/folders/1Rgxfiw",
  path = "/home/user/downloads"
)

# Download only files matching specific patterns
download_google_drive(
  url = "https://drive.google.com/drive/folders/1Rgxfiw",
  title = c("report", "data", ".csv")
)

# Download filtered files to specific directory
result_path <- download_google_drive(
  url = "https://drive.google.com/drive/folders/1Rgxfiw",
  path = "./my_data",
  title = c("analysis", "results")
)
} # }