Retrieve metadata for files specified via path or via file id.

If the files are specified via path, the returned dribble will include a path variable. To add path information to any dribble that lacks it, use drive_reveal(), e.g., drive_reveal(d, "path"). If you want to list the contents of a folder, use drive_ls(). For general searching, use drive_find().

Note: Team Drives are only available to users of certain enhanced Google services, such as G Suite Enterprise, G Suite Business, or G Suite for Education.

drive_get(path = NULL, id = NULL, team_drive = NULL, corpus = NULL,
  verbose = TRUE)



Character vector of path(s) to get. Use a trailing slash to indicate explicitly that a path is a folder, which can disambiguate if there is a file of the same name (yes this is possible on Drive!). A character vector marked with as_id() is treated as if it was provided via the id argument.


Character vector of Drive file ids or URLs (it is first processed with as_id()). If both path and id are non-NULL, id is silently ignored.


Anything that identifies one specific Team Drive: its name, its id or URL marked with as_id(), or a dribble. Is pre-processed with as_team_drive(). Read more about Team Drives.


Character, specifying the search collection. Only relevant in the Team Drives context. If specified, must be one of "user", "all", or "domain". Read more about Team Drives.


Logical, indicating whether to print informative messages (default TRUE).


An object of class dribble, a tibble with one row per item.

Special considerations for paths

Note that Google Drive does NOT behave like your local file system:

  • File and folder names need not be unique, even at a given level of the hierarchy. A single name or file path can be associated with multiple files (or zero or exactly one).

  • A file can have more than one direct parent. This implies that a single file can be represented by multiple paths.

Bottom line: Do not assume there is a one-to-one relationship between file name or path and a Drive file or folder. This implies the length of the input (i.e. the number of input paths or the number of rows in a dribble) will not necessarily equal the number rows in the output.

See also

Wraps the files.get endpoint and, if you specify files by name or path, also calls files.list:


## get info about your "My Drive" root folder
## the API reserves the file id "root" for your root folder
drive_get(id = "root")
drive_get(id = "root") %>% drive_reveal("path")

## multiple names
drive_get(c("abc", "def"))

## multiple names, one of which must be a folder
drive_get(c("abc", "def/"))

## query by file id(s)
drive_get(id = "abcdefgeh123456789")
drive_get(id = c("abcdefgh123456789", "jklmnopq123456789"))

## access the Team Drive named "foo"
## team_drive params must be specified if getting by path
foo <- team_drive_get("foo")
drive_get(c("this.jpg", "that-file"), team_drive = foo)
## team_drive params are not necessary if getting by id

## search all Team Drives and other files user has accessed
drive_get(c("this.jpg", "that-file"), corpus = "all")
# }