Bulk delete orphan files on G Drive using GAM?

1,038 views
Skip to first unread message

Jason Galati

unread,
Apr 25, 2017, 6:28:06 AM4/25/17
to GAM for G Suite
Hey yoll,

Is there anyway to achieve this?
eg... something like ; gam user jsm...@acme.com delete drivefile "query:is:unorganized owner:me'" purge

This is to remove a huge amount of orphaned files, since doing it via drive manually only lets you delete a few at once:

Thanks

Caleb Spring

unread,
Apr 25, 2017, 2:23:07 PM4/25/17
to GAM for G Suite
+1

Ross Scroggs

unread,
Apr 25, 2017, 2:55:19 PM4/25/17
to google-ap...@googlegroups.com
Caleb/Jason,

You can do this in my advanced gam: https://github.com/taers232c/GAMADV-X
First, find the orphans:
gam redirect csv ./testuser_orphans.csv user test...@domain.com print filelist select orphans fields id,title

This gives you a CSV file with headings: Owner,id,title
Inspect testuser_orphans.csv, if it seems reasonable, proceed.

Purge the files:
gam redirect stdout ./testuser_orphans_purged.txt multiprocess redirect stderr stdout csv ./testuser_orphans.csv gam user ~Owner purge drivefile ~id

Contact me directly with further questions,

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-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/414becf3-632e-4a06-9480-1adf06c4967a%40googlegroups.com.

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



--

Caleb Spring

unread,
Apr 25, 2017, 4:54:42 PM4/25/17
to GAM for G Suite
I started playing around with GAMADV-X before posting this but I am not advanced enough to figure it out :). Ran your command and it worked perfectly. Thank Ross

On Tuesday, April 25, 2017 at 2:55:19 PM UTC-4, Ross Scroggs wrote:
Caleb/Jason,

You can do this in my advanced gam: https://github.com/taers232c/GAMADV-X
First, find the orphans:
gam redirect csv ./testuser_orphans.csv user test...@domain.com print filelist select orphans fields id,title

This gives you a CSV file with headings: Owner,id,title
Inspect testuser_orphans.csv, if it seems reasonable, proceed.

Purge the files:
gam redirect stdout ./testuser_orphans_purged.txt multiprocess redirect stderr stdout csv ./testuser_orphans.csv gam user ~Owner purge drivefile ~id

Contact me directly with further questions,

Ross



On Tue, Apr 25, 2017 at 11:23 AM, Caleb Spring <csp...@vnnlaw.com> wrote:
+1

On Tuesday, April 25, 2017 at 6:28:06 AM UTC-4, Jason Galati wrote:
Hey yoll,

Is there anyway to achieve this?
eg... something like ; gam user jsm...@acme.com delete drivefile "query:is:unorganized owner:me'" purge

This is to remove a huge amount of orphaned files, since doing it via drive manually only lets you delete a few at once:

Thanks

--
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.



--

Jason Galati

unread,
Apr 26, 2017, 3:35:01 AM4/26/17
to GAM for G Suite
Thanks for the quick reply. I'll give that a go. Mystery solved.


On Tuesday, 25 April 2017 20:55:19 UTC+2, Ross Scroggs wrote:
Caleb/Jason,

You can do this in my advanced gam: https://github.com/taers232c/GAMADV-X
First, find the orphans:
gam redirect csv ./testuser_orphans.csv user test...@domain.com print filelist select orphans fields id,title

This gives you a CSV file with headings: Owner,id,title
Inspect testuser_orphans.csv, if it seems reasonable, proceed.

Purge the files:
gam redirect stdout ./testuser_orphans_purged.txt multiprocess redirect stderr stdout csv ./testuser_orphans.csv gam user ~Owner purge drivefile ~id

Contact me directly with further questions,

Ross



On Tue, Apr 25, 2017 at 11:23 AM, Caleb Spring <csp...@vnnlaw.com> wrote:
+1

On Tuesday, April 25, 2017 at 6:28:06 AM UTC-4, Jason Galati wrote:
Hey yoll,

Is there anyway to achieve this?
eg... something like ; gam user jsm...@acme.com delete drivefile "query:is:unorganized owner:me'" purge

This is to remove a huge amount of orphaned files, since doing it via drive manually only lets you delete a few at once:

Thanks

--
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.



--

Jason Galati

unread,
Apr 26, 2017, 3:54:39 AM4/26/17
to GAM for G Suite
Not sure what i'm doing wrong here..? the command generateds an empty CSV with the columns: own, id, title and no data:
gam select h1 redirect csv ./user_orphans.csv user te...@domain.com print filelist select orphans fields id,title

Upon running, does give:
Getting all Drive Files/Folders that match query ('me' in owners) for test...@test.com
Got 460 Drive Files/Folders for test...@test.com...
Got 920 Drive Files/Folders for test...@test.com...
Got 1380 Drive Files/Folders for test...@test.com...
Got 1840 Drive Files/Folders for test...@test.com...
Got 2300 Drive Files/Folders for test...@test.com...
Got 2760 Drive Files/Folders for test...@test.com...
Got 3220 Drive Files/Folders for test...@test.com...
Got 3680 Drive Files/Folders for test...@test.com...
Got 4140 Drive Files/Folders for test...@test.com...
Got 4600 Drive Files/Folders for test...@test.com...
Got 4684 Drive Files/Folders for test...@test.com...

Thanks

On Tuesday, 25 April 2017 20:55:19 UTC+2, Ross Scroggs wrote:
Caleb/Jason,

You can do this in my advanced gam: https://github.com/taers232c/GAMADV-X
First, find the orphans:
gam redirect csv ./testuser_orphans.csv user test...@domain.com print filelist select orphans fields id,title

This gives you a CSV file with headings: Owner,id,title
Inspect testuser_orphans.csv, if it seems reasonable, proceed.

Purge the files:
gam redirect stdout ./testuser_orphans_purged.txt multiprocess redirect stderr stdout csv ./testuser_orphans.csv gam user ~Owner purge drivefile ~id

Contact me directly with further questions,

Ross



On Tue, Apr 25, 2017 at 11:23 AM, Caleb Spring <csp...@vnnlaw.com> wrote:
+1

On Tuesday, April 25, 2017 at 6:28:06 AM UTC-4, Jason Galati wrote:
Hey yoll,

Is there anyway to achieve this?
eg... something like ; gam user jsm...@acme.com delete drivefile "query:is:unorganized owner:me'" purge

This is to remove a huge amount of orphaned files, since doing it via drive manually only lets you delete a few at once:

Thanks

--
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.



--

Jason Galati

unread,
Apr 28, 2017, 6:01:46 AM4/28/17
to GAM for G Suite
Is there perhaps a file limit on this command?
The command works for some users but stops half way on others.


On Tuesday, 25 April 2017 20:55:19 UTC+2, Ross Scroggs wrote:
Caleb/Jason,

You can do this in my advanced gam: https://github.com/taers232c/GAMADV-X
First, find the orphans:
gam redirect csv ./testuser_orphans.csv user test...@domain.com print filelist select orphans fields id,title

This gives you a CSV file with headings: Owner,id,title
Inspect testuser_orphans.csv, if it seems reasonable, proceed.

Purge the files:
gam redirect stdout ./testuser_orphans_purged.txt multiprocess redirect stderr stdout csv ./testuser_orphans.csv gam user ~Owner purge drivefile ~id

Contact me directly with further questions,

Ross



On Tue, Apr 25, 2017 at 11:23 AM, Caleb Spring <csp...@vnnlaw.com> wrote:
+1

On Tuesday, April 25, 2017 at 6:28:06 AM UTC-4, Jason Galati wrote:
Hey yoll,

Is there anyway to achieve this?
eg... something like ; gam user jsm...@acme.com delete drivefile "query:is:unorganized owner:me'" purge

This is to remove a huge amount of orphaned files, since doing it via drive manually only lets you delete a few at once:

Thanks

--
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,
Apr 28, 2017, 12:03:11 PM4/28/17
to google-ap...@googlegroups.com
Jason,

What is "stops half way"?

Ross

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-ap...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-apps-manager.



--

--
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.



--

Jason Galati

unread,
May 2, 2017, 3:04:50 AM5/2/17
to GAM for G Suite
Meaning -the command doesn't finish. It deletes some files but goes no further.

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.
Visit this group at https://groups.google.com/group/google-apps-manager.



--

--
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.
Visit this group at https://groups.google.com/group/google-apps-manager.



--

Ross Scroggs

unread,
May 3, 2017, 9:52:32 AM5/3/17
to google-ap...@googlegroups.com
Jason,

Send me a direct email at ross.s...@gmail.com.

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

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

Jason Galati

unread,
May 4, 2017, 6:57:01 AM5/4/17
to GAM for G Suite
Not sure what happened. Maybe user deleted some files.
But I waited a day and tried again and it works this time! Thanks
Reply all
Reply to author
Forward
0 new messages