Skip to contents

Accepts either a bare Google Drive ID or a full Drive/Docs URL and returns the ID only. Handles folder URLs (.../folders/{id}), file/document URLs (.../d/{id}/...), and ?id= query forms. A value that is already a bare ID is returned unchanged.

Usage

parse_drive_id(x)

Arguments

x

Character scalar. A Google Drive ID or URL.

Value

Character scalar with the Google Drive ID.

Examples

parse_drive_id("https://drive.google.com/drive/u/0/folders/1Q21PGqwNketz5gWhww")
#> [1] "1Q21PGqwNketz5gWhww"
parse_drive_id("https://docs.google.com/document/d/1sZVw7U5O7ElXZ/edit")
#> [1] "1sZVw7U5O7ElXZ"
parse_drive_id("1sZVw7U5O7ElXZ")
#> [1] "1sZVw7U5O7ElXZ"