Skip to contents

Reads a project's Project object from the datalake, resolves its google_drive_id folder, and lists every file in that folder (recursively). Pass path to scope the listing to a subfolder, which is much faster than walking the whole tree.

Usage

gdrive_ls(path = NULL, newest_first = TRUE, project = dl_get_project())

Arguments

path

Character. Optional subfolder path relative to the project's Drive root (e.g. "results" or "R/data_cleaning"). When given, only that subfolder is listed; name stays relative to the project root. Default NULL lists the whole tree.

newest_first

Logical. If TRUE (default), order files from most- to least-recently updated. If FALSE, keep Google Drive's original order.

project

Character scalar. Project ID to load from the datalake. Defaults to dl_get_project(). Must refer to an existing project initialized with dl_project_init().

Value

A tibble with one row per file and columns:

  • id — Google Drive file ID.

  • name — a clickable gdrive_path: the file path relative to the project's Drive root, hyperlinked to the file. Use as.character() to get the plain path string.

  • type — friendly file type derived from the Drive MIME type (e.g. "Google Sheet", "Word", "PDF"); falls back to the file extension.

  • last_modified — timestamp the file was last updated (POSIXct).

Details

Unlike a raw googledrive::drive_ls() call, the name column is the file's path relative to the project's Drive root (e.g. "Survey/Gradient exclusive copy of WW Qualtrics survey.docx"), reconstructed by walking each file's parent-folder chain. It is rendered as a clickable link to the file (in terminals that support hyperlinks). Folders themselves are omitted from the result — they are represented by the path prefix.

Examples

if (FALSE) { # \dontrun{
gdrive_ls()
gdrive_ls(project = "sentinel")
gdrive_ls(path = "results")
gdrive_ls(newest_first = FALSE)
} # }