James;
I'm assuming you are using advance gam. This will be a two step process.
First get all your users;
> gam redirect csv ./allusers.csv print users fields ou,suspended
The above command will get you all of your users plus their OU and suspended status.
Next pull all of the top level orphan file information for each user as below and merge the OU and status information from the previous output with it.
> gam redirect csv ./allorphans.csv multiprocess csv ./allusers.csv gam user ~primaryEmail print filelist choose orphans fields id,name,mimetype,modifiedTime,size,owners.emailaddress filepath depth 0 addcsvdata orgUnitPath ~orgUnitPath addcsvdata suspended ~suspended showownedby any
This will get only the top level orphans, so just the orphaned folders of anything that isn't at the root level. I'm assuming that if you know the parent folder is an orphan all of its children still belong to the folder so you can manipulate the orphan folder and all it children will follow. Here's a breakdown of the command:
1. gam redirect csv ./allorphans.csv - this will be the final output file
2. multiprocess csv ./allusers.csv - this tells gam to read each record from ./allusers.csv and process all the files for each users in the following gam command and merge it into the output
3 gam user ~primaryEmail print filelist choose orphans - tell gam to find all of the orphans for a single user from the input csv
4. fields id,name,mimetype,modifiedTime,size,owners.emailaddress, filepath depth 0 - tell gam what fields from the file search to send to the output
5. addcsvdata ourUnitPaht, ~ourUnitPaht addcsvdata suspended ~suspended - merge the OU and status from the input csv with each record
6. showownedby any - select files owned by anyone, this is probably not necessary.
Depending on the size of your account this might take some time.