Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

drive: add `-o config` option to `backend drives` to config for all shared drives

Nick Craig-Woodc821fbeddf67
diff --git a/backend/drive/drive.go b/backend/drive/drive.go
index bdc80bc79..12282889e 100755
--- a/backend/drive/drive.go
+++ b/backend/drive/drive.go
@@ -3162,7 +3162,7 @@ account.
Usage:
- rclone backend drives drive:
+ rclone backend [-o config] drives drive:
This will return a JSON list of objects like this
@@ -3179,6 +3179,22 @@ This will return a JSON list of objects like this
}
]
+With the -o config parameter it will output the list in a format
+suitable for adding to a config file to make aliases for all the
+drives found.
+
+ [My Drive]
+ type = alias
+ remote = drive,team_drive=0ABCDEF-01234567890,root_folder_id=:
+
+ [Test Drive]
+ type = alias
+ remote = drive,team_drive=0ABCDEFabcdefghijkl,root_folder_id=:
+
+Adding this to the rclone config file will cause those team drives to
+be accessible with the aliases shown. This may require manual editing
+of the names.
+
`,
}, {
Name: "untrash",
@@ -3290,7 +3306,21 @@ func (f *Fs) Command(ctx context.Context, name string, arg []string, opt map[str
}
return f.makeShortcut(ctx, arg[0], dstFs, arg[1])
case "drives":
- return f.listTeamDrives(ctx)
+ drives, err := f.listTeamDrives(ctx)
+ if err != nil {
+ return nil, err
+ }
+ if _, ok := opt["config"]; ok {
+ lines := []string{}
+ for _, drive := range drives {
+ lines = append(lines, "")
+ lines = append(lines, fmt.Sprintf("[%s]", drive.Name))
+ lines = append(lines, fmt.Sprintf("type = alias"))
+ lines = append(lines, fmt.Sprintf("remote = %s,team_drive=%s,root_folder_id=:", f.name, drive.Id))
+ }
+ return lines, nil
+ }
+ return drives, nil
case "untrash":
dir := ""
if len(arg) > 0 {