deleting all user content in their drive but having gam skip things that may be in the shared with m

2,389 views
Skip to first unread message

Bent Lee

unread,
Dec 6, 2017, 10:57:58 AM12/6/17
to GAM for G Suite
Here is my situation
I run a lot of exam accounts. These accounts have bookmarks that are shared with them to drive files belonging to another user. 
The student logs on and goes to bookmarks that are pushed. These files are audio files.
The student then opens google docs and creates a doc and shares that with the teacher. . After the exam we lock the account.  We retain these docs for 30 days. 

After 30 days I run a gam command that deletes those docs.
My command is as follows

gam ou "/ExamWriters/English/Chem" delete drivefile "query:mimeType !='application.vnd.google-apps.folder'" purge

The issue is it fails because there are bookmarks that show under the shared with me. The gam command simple stops.

Thanks for your help

Ross Scroggs

unread,
Dec 6, 2017, 1:49:56 PM12/6/17
to google-ap...@googlegroups.com
Bent,

Do the following for some user and an audio file: gam user us...@domain.com show fileinfo <DriveFileIDhere>
Grab the mimeType and extend the query:
gam ou "/ExamWriters/English/Chem" delete drivefile "query:mimeType !='application.vnd.google-apps.folder' and mimeType !='put audiomimetypehere'" purge

Ross

This email and any files transmitted with it are intended solely for
use by the recipient(s) to whom it is addressed and may contain
confidential information. If you have received this email in error please

notify the sender immediately and permanently delete this email and/or any files attached to it from your computer

Oh yea...I can't purchase on behalf either

--
You received this message because you are subscribed to the Google Groups "GAM for G Suite" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-manager+unsub...@googlegroups.com.
To post to this group, send email to google-apps-manager@googlegroups.com.
Visit this group at https://groups.google.com/group/google-apps-manager.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-manager/cf81fd67-0d93-4245-81ae-3628472b7763%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Bent Lee

unread,
Dec 6, 2017, 2:19:52 PM12/6/17
to GAM for G Suite
Sorry I am not sure if I fully understand correctly . I do want the bookmark (which is a drive folder  with audio content to stay, but I also want any folders and documents the user created to be deleted.

I figured out how to get an export files id with 

gam ou "ExamWriters/English/BIO" show filelist  id name >biolistall.csv  
That gives me a file

The headers in the file are Owner, id and Title

I then try to use that csv file to delete the files by id in bulk since i have all the users and their files
My command is gam csv biolistall.csv gam delete drivefile Owner ~Owner  id ~id                 That fails
I tried gam csv biolistall.csv gam delete drivefile   id ~id                 That fails


I tried gam user name @domain delete drivefile 1Kix8v2o9j  and that works

I then tried gam csv biolistall.csv gam user Owner ~Owner delete drivefile   id ~id                 That fails
I then tried gam csv biolistall.csv gam user delete drivefile Owner ~Owner    id ~id That fails


I tried a bunch of ways but everything fails when I try the bulk delete


Can you tell me what I might be doing wrong...I really appreciate your help

Thanks



On Wednesday, December 6, 2017 at 11:49:56 AM UTC-7, Ross Scroggs wrote:
Bent,

Do the following for some user and an audio file: gam user us...@domain.com show fileinfo <DriveFileIDhere>
Grab the mimeType and extend the query:
gam ou "/ExamWriters/English/Chem" delete drivefile "query:mimeType !='application.vnd.google-apps.folder' and mimeType !='put audiomimetypehere'" purge

Ross
On Wed, Dec 6, 2017 at 7:57 AM, Bent Lee <bent...@wolfapps.ca> wrote:
Here is my situation
I run a lot of exam accounts. These accounts have bookmarks that are shared with them to drive files belonging to another user. 
The student logs on and goes to bookmarks that are pushed. These files are audio files.
The student then opens google docs and creates a doc and shares that with the teacher. . After the exam we lock the account.  We retain these docs for 30 days. 

After 30 days I run a gam command that deletes those docs.
My command is as follows

gam ou "/ExamWriters/English/Chem" delete drivefile "query:mimeType !='application.vnd.google-apps.folder'" purge

The issue is it fails because there are bookmarks that show under the shared with me. The gam command simple stops.

Thanks for your help

This email and any files transmitted with it are intended solely for
use by the recipient(s) to whom it is addressed and may contain
confidential information. If you have received this email in error please

notify the sender immediately and permanently delete this email and/or any files attached to it from your computer

Oh yea...I can't purchase on behalf either

--
You received this message because you are subscribed to the Google Groups "GAM for G Suite" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-manager+unsub...@googlegroups.com.
To post to this group, send email to google-ap...@googlegroups.com.



--

Ross Scroggs

unread,
Dec 6, 2017, 2:56:12 PM12/6/17
to google-ap...@googlegroups.com
Bent,

This should delete all files that aren't folders and aren't audio files (audio/x-wav).

gam ou "/ExamWriters/English/Chem" delete drivefile "query:mimeType !='application.vnd.google-apps.folder' and mimeType !='audio/x-wav'"
Note that it should be application/vnd.google-apps.folder (/, not .)

Test like this: gam user test...@domain.com print filelist query "mimeType!='application/vnd.google-apps.folder' and mimeType!='audio/x-wav'" id title mimetype

This command: gam csv biolistall.csv gam delete drivefile Owner ~Owner  id ~id
should be: gam csv biolistall.csv gam user ~Owner delete drivefile  ~id

Ross

To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-manager+unsubscribe...@googlegroups.com.



--

This email and any files transmitted with it are intended solely for
use by the recipient(s) to whom it is addressed and may contain
confidential information. If you have received this email in error please

notify the sender immediately and permanently delete this email and/or any files attached to it from your computer

Oh yea...I can't purchase on behalf either

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

For more options, visit https://groups.google.com/d/optout.



--

Bent Lee

unread,
Dec 7, 2017, 12:29:06 PM12/7/17
to GAM for G Suite
Ross ..I just wanted to thank you for all your help. I hope you are having a great week.

Bent

Ross Scroggs

unread,
Dec 7, 2017, 12:32:14 PM12/7/17
to google-ap...@googlegroups.com
Bent,

Did you get the delete to work?

Ross

This email and any files transmitted with it are intended solely for
use by the recipient(s) to whom it is addressed and may contain
confidential information. If you have received this email in error please

notify the sender immediately and permanently delete this email and/or any files attached to it from your computer

Oh yea...I can't purchase on behalf either

--
You received this message because you are subscribed to the Google Groups "GAM for G Suite" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-manager+unsub...@googlegroups.com.
To post to this group, send email to google-apps-manager@googlegroups.com.
Visit this group at https://groups.google.com/group/google-apps-manager.

For more options, visit https://groups.google.com/d/optout.



--

Bent Lee

unread,
Dec 20, 2017, 3:38:58 PM12/20/17
to google-ap...@googlegroups.com
It all worked flawlessly.
Thanks

On Thu, Dec 7, 2017 at 10:32 AM, Ross Scroggs <ross.s...@gmail.com> wrote:
Bent,

Did you get the delete to work?

Ross
On Thu, Dec 7, 2017 at 9:29 AM, Bent Lee <bent...@wolfapps.ca> wrote:
Ross ..I just wanted to thank you for all your help. I hope you are having a great week.

Bent

On Wednesday, December 6, 2017 at 8:57:58 AM UTC-7, Bent Lee wrote:
Here is my situation
I run a lot of exam accounts. These accounts have bookmarks that are shared with them to drive files belonging to another user. 
The student logs on and goes to bookmarks that are pushed. These files are audio files.
The student then opens google docs and creates a doc and shares that with the teacher. . After the exam we lock the account.  We retain these docs for 30 days. 

After 30 days I run a gam command that deletes those docs.
My command is as follows

gam ou "/ExamWriters/English/Chem" delete drivefile "query:mimeType !='application.vnd.google-apps.folder'" purge

The issue is it fails because there are bookmarks that show under the shared with me. The gam command simple stops.

Thanks for your help

This email and any files transmitted with it are intended solely for
use by the recipient(s) to whom it is addressed and may contain
confidential information. If you have received this email in error please

notify the sender immediately and permanently delete this email and/or any files attached to it from your computer

Oh yea...I can't purchase on behalf either

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

To post to this group, send email to google-apps-manager@googlegroups.com.
Visit this group at https://groups.google.com/group/google-apps-manager.



--

--
You received this message because you are subscribed to a topic in the Google Groups "GAM for G Suite" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-apps-manager/HFoPJb71hJE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-apps-manager+unsub...@googlegroups.com.

To post to this group, send email to google-apps-manager@googlegroups.com.
Visit this group at https://groups.google.com/group/google-apps-manager.

For more options, visit https://groups.google.com/d/optout.

Bent Lee

unread,
Apr 12, 2018, 1:29:47 PM4/12/18
to google-ap...@googlegroups.com
Hi Ross,
I truly appreciated your help last time
I am back again trying to figure out how I can build a list of files that are owned by specific users

My command I am trying  is  Gam csv filelisttestaccounts.csv  gam user ~Email show filelist id name > testfilelisttestaccounts3.csv (my filelisttestaccounts.csv has only a header of Email)

When I run it I get results of Owner ID and Title listed between each user . I would prefer not to have these headings between users
On top of that I get some titles like looks like 1.49E+12 in the column title
One of my users in the list show 10 files. When I look in the users drive I see two files listed under quick access. These same files show under Files. Also under Folder I have 1 folder and inside it there is only 1 file
Nothing adds up to 10 at best between the folder and files I count 4 ( the two files, The folder and the files inside of the folder.


Later I want to run the command
That purges those files
I thought it would be something like

gam csv testfilelisttestaccounts3.csv gam user ~Owner delete drivefile  ~id purge


Thank you ever so much for any help you can give me.


Bent






This email and any files transmitted with it are intended solely for
use by the recipient(s) to whom it is addressed and may contain
confidential information. If you have received this email in error please

notify the sender immediately and permanently delete this email and/or any files attached to it from your computer

Oh yea...I can't purchase on behalf either

--
You received this message because you are subscribed to a topic in the Google Groups "GAM for G Suite" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-apps-manager/HFoPJb71hJE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-apps-manager+unsub...@googlegroups.com.
To post to this group, send email to google-apps-manager@googlegroups.com.
Visit this group at https://groups.google.com/group/google-apps-manager.

For more options, visit https://groups.google.com/d/optout.

anthony jimenez

unread,
Aug 5, 2020, 5:39:52 PM8/5/20
to GAM for G Suite
ok so what if i wanted to just delete all of a users content but keep the user? 

Ross Scroggs

unread,
Aug 5, 2020, 6:08:34 PM8/5/20
to google-ap...@googlegroups.com
Anthony,

gam user us...@domain.com print filelist id > files.csv

gam csv files.csv gam user "~Owner" delete drivefile "~id" purge


Be sure that this is what you want to do.


Ross


--
You received this message because you are subscribed to the Google Groups "GAM for G Suite" 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/12f08edf-15be-4c6b-95d9-27fd7a6ddf29o%40googlegroups.com.


--

anthony jimenez

unread,
Aug 5, 2020, 6:25:34 PM8/5/20
to GAM for G Suite
awesome thanks


On Wednesday, August 5, 2020 at 3:08:34 PM UTC-7, Ross Scroggs wrote:
Anthony,

gam user us...@domain.com print filelist id > files.csv

gam csv files.csv gam user "~Owner" delete drivefile "~id" purge


Be sure that this is what you want to do.


Ross


On Wed, Aug 5, 2020 at 2:39 PM anthony jimenez <anthony...@gmail.com> wrote:
ok so what if i wanted to just delete all of a users content but keep the user? 

On Wednesday, December 6, 2017 at 7:57:58 AM UTC-8, Bent Lee wrote:
Here is my situation
I run a lot of exam accounts. These accounts have bookmarks that are shared with them to drive files belonging to another user. 
The student logs on and goes to bookmarks that are pushed. These files are audio files.
The student then opens google docs and creates a doc and shares that with the teacher. . After the exam we lock the account.  We retain these docs for 30 days. 

After 30 days I run a gam command that deletes those docs.
My command is as follows

gam ou "/ExamWriters/English/Chem" delete drivefile "query:mimeType !='application.vnd.google-apps.folder'" purge

The issue is it fails because there are bookmarks that show under the shared with me. The gam command simple stops.

Thanks for your help

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


--
Ross Scroggs

JoelC

unread,
Apr 26, 2021, 10:54:31 AM4/26/21
to GAM for Google Workspace
Hi Ross,

Is there another way to accomplish this for a user that has tons of files?  The first command to build the file list fails after many hours of running on one of my users that has tens of thousands of files.

Thanks!
Joel

Brian Kim

unread,
Apr 26, 2021, 12:40:10 PM4/26/21
to GAM for Google Workspace
You may want to consider running it in a VM with enough memory to build the filelist. (16GB or higher).

JoelC

unread,
Aug 30, 2021, 12:23:35 PM8/30/21
to GAM for Google Workspace
Hi Ross,

Thanks again for all your help!

How would I get a list of all "non-Google" files using the mimeType querry?

Would it just be gam user print filelist query "not mimeType = 'application/vnd.google-apps.folder'"

Thanks!
Joel

Reply all
Reply to author
Forward
0 new messages