Move Shared Drive to User drive

221 views
Skip to first unread message

Jonathan Tarro

unread,
Feb 23, 2023, 9:14:31 AM2/23/23
to GAM for Google Workspace
Hello, I am needing to move a Shared Drive to within a user drive.  

I found some breadcrumbs (listed below) which led me to try:
  • gam user<user_email> move drivefile teamdriveid <driveid>
From this though I get the error - "ERROR: 403: fileNeverWritable - This file is never writable."

**Does anyone know what I am missing here?**

-Speaks of "Complex moves" as well as Shared drive to Shared drive moves - https://github.com/taers232c/GAMADV-XTD3/wiki/Users-Drive-Copy-Move#move-files-and-folders
-I use this to move userdrive to a different userdrive - gam user <user_email> transfer drive <Sourcedrive> retainrole writer nonowner_targetrole source

Ross Scroggs

unread,
Feb 25, 2023, 5:21:44 PM2/25/23
to google-ap...@googlegroups.com
What are you trying to do?

Ross
----
Ross Scroggs



--
You received this message because you are subscribed to the Google Groups "GAM for Google Workspace" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-man...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-manager/9d4d42cd-a91d-45dd-928b-a98a7134478an%40googlegroups.com.

Kim Nilsson

unread,
Feb 26, 2023, 2:56:37 AM2/26/23
to GAM for Google Workspace
Jonathan, that's not possible.
You can print the files and folders in the Shared Drive, and move them, but you can never move the actual Shared Drive.
Message has been deleted

Jonathan Tarro

unread,
Feb 27, 2023, 10:16:31 AM2/27/23
to GAM for Google Workspace
So we are really just starting the process to cleanup what is expected abandoned google shared drives.  I've found one of your older posts and found it fairly quick to change the parentid to another shared drive so I am thinking about going that route.  I was thinking about creating a folder on the source shared drive and moving all of the current files on that shared drive to the folder before transferring the parent to my target shared drive.  

In your opinion would the be the most efficient way to do this?
Could I do this with a few simple commands or will I have to print all of the current file ID's to a file and then import that file and move them that way?

Any breadcrumbs you could share on moving these files?

Thanks for your help!

Jon

Kim Nilsson

unread,
Feb 27, 2023, 1:04:15 PM2/27/23
to GAM for Google Workspace
I don't think there's a trick command to do what you want in one step.

But the path you mentioned is fairly straightforward.
Print all the files in each Shared Drive, and move them into new folders you create in a destination Shared Drive.

Remember that you can max have 400k files and 20 folders deep in each Shared Drive.

Jonathan Tarro

unread,
Feb 28, 2023, 12:58:08 PM2/28/23
to GAM for Google Workspace
So would it be best practice to:
1)create a directory in the source shared drive, print the source drive files / move the files to that subdirectory and then transfer the parent of that directory to the other shared drive
or
2) print the source drive files / move the files to the target shared drive --//or is this even possible?

I am having some trouble with the documentation relating to movement from one location to the other.  I am looking for the below command to move the files to either a subfolder on the current source shared drive or a specific subfolder on the target shared drive:

gam user <userid> print filelist select teamdrive <sourcedrive> | gam csv - gam user "~Owner" update drivefile id "~id" parentid <targetparentid>

Are you able to provide any assistance with this?

Kim Nilsson

unread,
Feb 28, 2023, 1:33:21 PM2/28/23
to google-ap...@googlegroups.com
In my mind the id of the target should be the folder of the destination.--
/Kim
--
There is No Substitute!

Jonathan Tarro

unread,
Feb 28, 2023, 2:43:15 PM2/28/23
to GAM for Google Workspace
Is there a way that I could get gam to keep the folder structure?

When I run the following it moves everything and though the folders are also moved, each of the files are placed in the root of the target share.
  • gam user $admusr print filelist select teamdrive "$myname" fields id,title,mimetype | gam csv - gam user "~Owner" update drivefile id "~id" parentid $dirid

Kim Nilsson

unread,
Feb 28, 2023, 2:50:54 PM2/28/23
to google-ap...@googlegroups.com
Of course.
That's the destination each transfer is told.

That's why you want to move only top folders and not subfolders or files.

Jonathan Tarro

unread,
Feb 28, 2023, 3:36:16 PM2/28/23
to GAM for Google Workspace
Not being able to move shared drive files to another location seems like a pretty large deficiency.   Am I using the wrong command then?

How is it that I can (within gam) transfer user drives to another drive and the process itself creates a subfolder and then transfers all documents recursively while maintaining existing structure?

Ross Scroggs

unread,
Feb 28, 2023, 3:40:33 PM2/28/23
to google-ap...@googlegroups.com
Jonathan,

If you want help from me, the author of Advanced GAM, send me a Meet/Zoom invitation.

Ross

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


--

Jonathan Tarro

unread,
Mar 1, 2023, 3:06:50 PM3/1/23
to GAM for Google Workspace
Thanks to everyone replying on this.  Especially thanks to Ross who took the time to set me straight relating to the "depth 0" switch.  This is what allowed the transfer to the target id to retain the folder structure.   I will post my script below in case it helps anyone (it is powershell).  

------------------------------------------------------------
<#
    .Description
     This script is meant to migrate a list of existing Google Shared Drives to an admin share.  It will first create a directory on the admin share with the name of the source share and then move everything into it.
.Requirements
 -This requires a list of team drives that have at least headers "id" and "name" to be named teamdrives.csv.  A full list of team drives in an org can be created with "gam print teamdrives >full_teams.csv"
 -The Admin used must be a Manager on both the Source and Target (admin) shares
 -Running this you will need the target share name ($admshare) and Google id ($admshareid) which can both be found in your full list of team drives

:Author Jonathan Tarro
#>

#set required variables
param (
    [parameter(Mandatory=$true)]
    [String]$admusr,
    [parameter(Mandatory=$true)]
    [String]$admshare,
    [parameter(Mandatory=$true)]
    [String]$admshareid
)

$drivecsv="teamdrives.csv"

#loop through source csv
Import-Csv $drivecsv | ForEach-Object {
#set variables from csv
$myname="$($_.name)"
$myid="$($_.id)"

write-host -ForegroundColor Blue -BackgroundColor Green "Currently migrating" $myname "/" $myid "to" $admshare

#create folder in target share with name of source share.  Save GAM result into variable
$cmdOutput=gam user $admusr create drivefile drivefilename $myname mimetype gfolder parentid $admshareid |out-string

#extract only Google id of new folder from GAM previous GAM result. Save id to variable
if($cmdOutput -match '\((.*)\)') { $dirid=$Matches[1] }

gam user $admusr print filelist select teamdrive "$myname" fields id,title,mimetype depth 0 | gam csv - gam user $admusr update drivefile id "~id" teamdriveparentid $dirid
}

Reply all
Reply to author
Forward
0 new messages