Automatically Create Folder & Share In Drive

778 views
Skip to first unread message

Zak Fleming

unread,
Oct 15, 2017, 1:24:32 PM10/15/17
to GAM for G Suite
Hello,

I am looking to use GAM to do the following. It isn't quite as simple as making a CSV as "add / delete drivefileacl" requires a unique file ID. I want to do the following on a few thousand user accounts. If anyone can point me in the right direction I would be grateful.

1. Create a folder in a users Google Drive named after their username with a space followed by the word migrated files. EG: "User1 Migrated Files"

2. Share this folder with a another account (migration account), this is shared to the same account for each user.

>>At this point I will use RCLONE to upload the users file into this shared folder<<

3. Change the ACL on the folder and all sub files and folders to change the owner to the user and remove the migration account from being shared with the files. This bit is optional, but will make tings tidy.

Any help would be great.

Thanks very much.

Ross Scroggs

unread,
Oct 15, 2017, 2:19:31 PM10/15/17
to google-ap...@googlegroups.com
Zak,

With GAMADV-X (https://github.com/taers232c/GAMADV-X), this should do what you want.

Make a CSV file MigratedUsers.csv with a two columns:

Owner,Name

flem...@wardletrust.co.uk,Zak

bo...@wardletrust.co.uk,James

...


1: Create "User Migrated Files" folder

gam csv MigratedUsers.csv gam user ~Owner add drivefile drivefilename "~~Name~~ Migrated Files" mimetype application/vnd.google-apps.folder


2: Share with Migration account

gam csv MigratedUsers.csv gam user ~Owner add drivefileacl drivefilename "~~Name~~ Migrated Files" user migr...@wardletrust.co.uk role writer


rclone


3: Claim ownership

gam csv MigratedUsers.csv gam user ~Owner claim ownership drivefilename "~~Name~~ Migrated Files"


4: Remove migration access

4a: Get list of files in all "User Migrated Files" folders

gam redirect csv ./MigratedPermissions.csv multiprocess csv MigratedUsers.csv gam user ~Owner print filelist select drivefilename "~~Name~~ Migrated Files" fields id,title


4b: Remove migration access to those files

gam csv MigratedPermissions.csv gam user ~Owner delete drivefileacl ~id migr...@wardletrust.co.uk


4c: Remove migration access to top folder

gam csv MigratedUsers.csv gam user ~Owner delete drivefileacl drivefilename "~~Name~~ Migrated Files" migr...@wardletrust.co.uk


Test with a couple of users, let me know the results.


I'll update claim ownership so that you can remove migr...@wardletrust.co.uk access in the same step; this would eliminate step 4.


Ross


--
You received this message because you are subscribed to the Google Groups "GAM for G Suite" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-manager+unsub...@googlegroups.com.
To post to this group, send email to google-apps-manager@googlegroups.com.
Visit this group at https://groups.google.com/group/google-apps-manager.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-manager/3d1d07c2-77f7-4d87-9ef4-b99d7089f40f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Zak Fleming

unread,
Oct 15, 2017, 2:23:56 PM10/15/17
to GAM for G Suite
Cheers Ross! I will give it a shot. Just about to have dinner so won't have time tonight, but will do it ASAP.

Cheers again

Zak
To post to this group, send email to google-ap...@googlegroups.com.



--

Ross Scroggs

unread,
Oct 15, 2017, 10:37:32 PM10/15/17
to google-ap...@googlegroups.com
Zak,

I've simplified your process and corrected a typo in the add drivefile command.

With GAMADV-X (https://github.com/taers232c/GAMADV-X), this should do what you want.
Make a CSV file MigratedUsers.csv with two columns:
Owner,Name
...

1: Create "User Migrated Files" folder
gam csv MigratedUsers.csv gam user ~Owner add drivefile drivefilename "~~Name~~ Migrated Files" mimetype gfolder

2: Share with Migration account
gam csv MigratedUsers.csv gam user ~Owner add drivefileacl drivefilename "~~Name~~ Migrated Files" user migr...@wardletrust.co.uk role writer

rclone

3: Claim ownership, delete migration account access
gam csv MigratedUsers.csv gam user ~Owner claim ownership drivefilename "~~Name~~ Migrated Files" retainrole none

Ross


--
You received this message because you are subscribed to the Google Groups "GAM for G Suite" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-man...@googlegroups.com.

+KimNilsson

unread,
Oct 16, 2017, 4:45:46 AM10/16/17
to GAM for G Suite
Thanks, Zak, for pushing Ross to new heights! :-)

This looks like several ideas that could simplify a migration process to G Suite.

Zak Fleming

unread,
Oct 27, 2017, 3:34:24 PM10/27/17
to GAM for G Suite
Hi All,

Sorry I haven't had chance to try this out yet. Personal life got in the way. I am hoping to get time to play this weekend.

Sorry for not getting back.

Thanks
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-manager+unsub...@googlegroups.com.

Zak Fleming

unread,
Oct 27, 2017, 3:35:02 PM10/27/17
to GAM for G Suite
And thanks for everyones input. Much appreciated.

Kim Nilsson

unread,
Oct 28, 2017, 5:49:44 AM10/28/17
to Google Apps Manager
Cool.
As I'm looking to do something similar, what would the rclone process / syntax look like?

Are you only cloning "local" files, from network storage, or are you able to clone from another G Suite domain, and then push to a new domain? 

Zak Fleming

unread,
Mar 2, 2018, 12:24:55 PM3/2/18
to GAM for G Suite
Hi All,

Sorry for the radio silence. I hadn't been very well, I then needed to rectify some of my certifications so the project was put on the back burner. 

I am going to give this a try very soon. I was wondering if anyone had done it since please?

Thanks

Zak Fleming

unread,
Mar 4, 2018, 11:06:12 AM3/4/18
to GAM for G Suite
Hi Ross,

I want to say thanks for the time with this. I have just tested it (manaul upload instead of Rclone and it seems to work flawlessly.

I was wondering what the difference and relationship GAM and GAMADV-X has please?

Thanks

Zak

On Monday, 16 October 2017 03:37:32 UTC+1, Ross Scroggs wrote:
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-manager+unsub...@googlegroups.com.

Ross Scroggs

unread,
Mar 4, 2018, 12:43:34 PM3/4/18
to google-ap...@googlegroups.com
Zak,

GAMADV-X is a rewrite of GAM; I contibute fixes and code cleanup to GAM; they are indepewndent projects.

Ross
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-man...@googlegroups.com.

To post to this group, send email to google-ap...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-apps-manager.

Zak Fleming

unread,
Mar 4, 2018, 3:25:08 PM3/4/18
to GAM for G Suite
I see!

Thanks very much for your efforts on this thread and the project as a whole!

Zak

Kim Nilsson

unread,
Mar 4, 2018, 4:11:11 PM3/4/18
to Google Apps Manager
Great.

Zak, would it be possible to see your rclone code?
You never did include it in earlier posts.

Just replace anything specific to your particular setup. Include the GAM parts too, if you please.

Zak Fleming

unread,
Mar 4, 2018, 4:18:57 PM3/4/18
to GAM for G Suite
Hello,

At the moment I haven't got into using a CSV. I am using a bog standard command. This is what I am using

rclone copy "C:\source folder" migration:"fUser1 Migrated Files" --drive-shared-with-me --stats=30s --stats-log-level NOTICE

When I sort out the CSV part I will let you know.

Thanks
Reply all
Reply to author
Forward
0 new messages