Using the method below in testing, the drive files were sent to the trash. We emptied the trash and still had the capability to administratively recover deleted/emptied trash files before they are permanently deleted after that (about 25 days I think).
This gives a safety net over "purge" which makes the deleted files permanently deleted.
The Comments have instruction on how to use it with some helpful GAM commands that I think you are looking for:
Usage:
1: Get information for all files, if you don't want all users, replace all users with your user selection
in the command below, e.g., ou /Students/Classof2019
These fields are required: fields id,name,owners.emailaddress
You can add additional fields that will be preserved in the output.
$ gam config auto_batch_min 1 redirect csv ./UserFiles.csv multiprocess all users print filelist fields id,name,owners.emailaddress fullpath
With an OU (For some reason I could not get it to work as described above):
$ gam config auto_batch_min 1 redirect csv ./UserFiles.csv multiprocess ou "Testou" print filelist fields id,name,owners.emailaddress fullpath
2: From that list of files, output a CSV file with the same headers as the input CSV file
that lists the drive file Ids that are not in the selected top level folders
$ python3 SelectiveDelete.py ./UserFiles.csv ./DeleteFiles.csv
3: Inspect DeleteFiles.csv, verify that it makes sense and then proceed
4: Delete the files (There is a typo in the git repo on this line, "./DetelteFiles.csv" should be "./DeleteFiles.csv" )
$ gam redirect stdout ./DeleteFiles.log multiprocess redirect stderr stdout csv ./DeleteFiles.csv gam user "~owners.0.emailAddress" delete drivefile "~id"
This was a good starting point for me and ended up writing commands (based on the above) to empty the trash too:
Empty Trash:
1: Get list of users to empty trash
$ gam config auto_batch_min 1 redirect csv ./Users.csv multiprocess all users print users
With OU (multiple OU's can be added, but should match above):
$ gam config auto_batch_min 1 redirect csv ./Users.csv multiprocess ous "TestOU" print users
2: Empty Trash for users
$ gam redirect stdout ./TrashCan.log multiprocess redirect stderr stdout csv ./Users.csv gam user "~user" empty drivetrash
I'm sure this could be streamlined, but it's a good place to start and hopefully adds some context.
This has worked for us in our test environment, and we will be running this on production soon.
Hope this is helpful for you!
~Seth