Moving all Google Drive files to folder in root

81 views
Skip to first unread message

Corey Schneer

unread,
Aug 7, 2024, 9:38:11 AM8/7/24
to google-ap...@googlegroups.com
Hi GAM community,

This past year, we migrated our schools to one Google workspace tenant, and standardized our student accounts. For the first year, our middle school kids will enter high school keeping their email accounts. We would like for the experience to be as clean as possible for them.

I would like to move all their files/folders, maintaining the structure, to a folder in the root of their Google Drive.

How can I go about this against an OU with GAM?

Thank you all.

--
Corey Schneer
Director of Information Technology
Magen David Yeshivah
718-954-3950 | internal: x.3950
ES/ECC/MS Tech Support: techs...@es.mdy.org
HS Tech Support: techs...@hs.mdy.org

website -     mdy.org

Ross Scroggs

unread,
Aug 7, 2024, 11:21:48 AM8/7/24
to google-ap...@googlegroups.com

# Get list of students in OU                                                                                                                                                                                                                                                    

gam redirect csv ./MSStudents.csv ou /MSStudents print users fields primaryemail

# redirect csv ./MSStudents.csv ou /MSStudents - List of student email addresses, replace with actual OU name                                                                                                                                                                   

# print users fields primaryemail                                                                                                                                                                                                                                               


# Get the top items in all Middle School student's My Drives                                                                                                                                                                                                                    

gam config num_threads 20 redirect csv ./MSStudentsTopItems.csv multiprocess redirect stdout - multiprocess redirect stderr stdout csv ./MSStudents.csv gam user "~primaryEmail" print filelist my_top_items fields id,name

# config num_threads 20 - Speed up processing                                                                                                                                                                                                                                   

# redirect csv ./MSStudentsTopItems.csv multiprocess - List of top level files/folders                                                                                                                                                                                          

# redirect stdout - multiprocess redirect stderr stdout - Clean progress messages                                                                                                                                                                                               

# gam user "~primaryEmail" print filelist my_top_items fields id,name - Get ids of files/folders directly in My Drive                                                                                                                                                           


# Create a folder to hold these items                                                                                                                                                                                                                                           

gam config num_threads 20 redirect stdout ./MakeMSStudentsNewFolder.txt multiprocess redirect stderr stdout csv ./MSStudents.csv gam user "~primaryEmail" create drivefile mimetype gfolder drivefilename "MSFiles" parentid root

# config auto_batch_min 1 num_threads 20 - Speed up processing                                                                                                                                                                                                                  

# redirect stdout ./MakeMSStudentsNewFolder.txt multiprocess redirect stderr stdout - Log folder creation                                                                                                                                                                       

# gam user "~primaryEmail" create drivefile mimetype gfolder drivefilename "MSFiles" parentid root - Create new top level folder, name as desired                                                                                                                               


# Move the top items into the new folder                                                                                                                                                                                                                                        

gam config num_threads 20 redirect stdout ./MoveMSStudentsTopItemsToNewFolder.txt multiprocess redirect stderr stdout csv ./MSStudentsTopItems.csv gam user "~Owner"  update drivefile "~id" parentname "MSFiles"

# Config num_threads 20 - Speed up processing                                                                                                                                                                                                                                   

# redirect stdout ./MoveMSStudentsTopItemsToNewFolder.txt multiprocess redirect stderr stdout - Log moving top level items into new folder                                                                                                                                      

# csv ./MSStudentsTopItems.csv - File created in first step                                                                                                                                                                                                                     

# gam user "~Owner" update drivefile "~id" parentname "MSFiles" - Move top level items into new folder, name as desired                                                                                                                                                         


You can test by making a MSStudents.csv file with header primaryEmail and one or two rows of email addresses



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/CAGSDd_nd6v4RybEtHy8TLkm9iCJid-g_hFRDptcJzuvymvycpQ%40mail.gmail.com.

Corey Schneer

unread,
Aug 8, 2024, 12:00:42 PM8/8/24
to google-ap...@googlegroups.com
Thank you Ross,

After this runs, It seems like the vast majority of the student files have been successfully moved, however, there are some stragglers here that remain in the root directory and don't seem to copy successfully.

Please let me know if there's anything else I can do.

Ross Scroggs

unread,
Aug 8, 2024, 12:16:14 PM8/8/24
to google-ap...@googlegroups.com
Corey,

Send me a Meet/Zoom invitation and we'll investigte.

Ross
----
Ross Scroggs


Reply all
Reply to author
Forward
0 new messages