We figured it out!
I was able to identify the specific files/folders that were truly orphaned by doing a search for is:unorganized owner:me in the users Google Drive web interface using the filter of the location Shared with me, and upon further inspection it was noted that all of these files have a parents.0.isRoot which is blank.
The first command we used created an "Orphaned Files" folder at the root of all the users I needed to run this command on, listed in users.csv, and put the folder ID's into orphan_folderid.csv:
gam redirect csv ./orphan_folderid.csv multiprocess csv users.csv gam user ~primaryemail create drivefile drivefilename "Orphaned Files" mimetype gfolder csv
The second command searches all of the users Google Drives for files/folders with the parent.0.isRoot as blank and puts a listing with the the relevant info such as email and File/Folder ID in a csv named orphans.csv:
gam config csv_output_row_filter "parents.0.isRoot:regex:^$" redirect csv ./orphans.csv multiprocess redirect stdout - multiprocess redirect stderr stdout csv orphan_folderid.csv gam user ~User print filelist fullquery "sharedWithMe=True and 'me' in owners" fields id,name,mimetype,owners.emailaddress,parents addcsvdata orphanparentid "~id"
The final command goes through orphans.csv and moves all of the orphaned files to the Orphaned Files folder created at the users root in the first command:
gam redirect stdout ./fixorphans.txt multiprocess redirect stderr stdout csv orphans.csv gam user ~Owner update drivefile ~id parentid "~orphanparentid"
Huge thank you to you Ross!
You're truly a gentleman, scholar and humanitarian sir.