Delete Drive Files Before Date

357 views
Skip to first unread message

Jason Jones

unread,
Sep 16, 2022, 9:59:10 AM9/16/22
to GAM for Google Workspace
Hello! 

Is it possible to delete all drive files prior  to a certain date using GAM? 

I can find pieces, but can't get the whole picture. 

This would be for student OU's only, not a domain wide deletion. 

Thank you!

Ross Scroggs

unread,
Sep 16, 2022, 10:38:12 AM9/16/22
to google-ap...@googlegroups.com
Jason,

gam ou "/Students/OU" delete drivefile query "createdTime<'2020-01-01T00:00:00Z'" purge


Ross


--
You received this message because you are subscribed to the Google Groups "GAM for Google Workspace" 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/951c13e1-ec59-4a7a-905e-26cfb523243an%40googlegroups.com.


--

Jason Jones

unread,
Oct 6, 2022, 4:54:15 PM10/6/22
to GAM for Google Workspace
Hey Ross! Finally got some breathing room to mess with this, and have tried several changes and still get an error. Doing in a test OU with a test user.

------------

gam ou "/Students/Withdrawals/test" delete drivefile query "createdTime<'2020-01-01T00:00:00Z'" purge
Getting all Users in Google Workspace account that match query (orgUnitPath='/Students/Withdrawals/test') (may take some time on a large account)...
Got 1 Users...
1 Users are directly in the OU.

ERROR: createdTime<'2020-01-01T00:00:00Z' is not a valid argument for "gam <users> delete drivefile"

Ross Scroggs

unread,
Oct 6, 2022, 5:28:20 PM10/6/22
to google-ap...@googlegroups.com
It looks like you're running Standard GAM, modify the command slightly; put a colon after query

gam ou "/Students/Withdrawals/test" delete drivefile query:"createdTime<'2020-01-01T00:00:00Z'" purge

Ross



--

Jason Jones

unread,
Oct 6, 2022, 5:31:50 PM10/6/22
to google-ap...@googlegroups.com
Hey Ross! I am getting ready to do family stuff. Any chance I can catch you tomorrow morning? 

I am getting a different error now with the change. Getting invalid query. 


------------

gam ou "/Students/Withdrawals/test" delete drivefile query:"createdTime<'2020-01-01T00:00:00Z'" purge
Getting all Users in Google Workspace account that match query (orgUnitPath='/Students/Withdrawals/test') (may take some time on a large account)...
Got 1 Users...
1 Users are directly in the OU.
Searching for files with query: "createdTime<'2020-01-01T00:00:00Z'"...

ERROR: 400: Invalid query - invalid




--
Image
Jason Jones
Systems Engineer | Managed Services
Five Star Technology Solutions
3310 E 10th St. Suite 4, #358
Jeffersonville, IN 47130
fivestartech.com
Company logo
facebook icon twitter icon linkedin icon instagram icon youtube icon 

Ross Scroggs

unread,
Oct 7, 2022, 4:06:30 AM10/7/22
to google-ap...@googlegroups.com
Jason,

I'm available starting at 7:45AM PDT.

Ross



--

Jason Komendat

unread,
Oct 19, 2022, 9:56:20 AM10/19/22
to GAM for Google Workspace
I was looking at doing something similiar. Just wonderting if anyone found thre right command for this.

Jason Jones

unread,
Nov 8, 2022, 5:33:30 PM11/8/22
to GAM for Google Workspace
Hey Ross! Would you have time to discuss this sometime this week? Perhaps 1:00 EST 11/9 or 11/10?

Jason Jones

unread,
Nov 9, 2022, 1:27:37 PM11/9/22
to GAM for Google Workspace
Using  gam ou "/Students/Withdrawals/test" delete drivefile query:"createdTime<'2020-01-01T00:00:00Z'" purge

It runs and gets the 1 user in that OU. 

Then I get "Searching for files with query: "createdTime<'2020-01-01T00:00:00Z'"...


ERROR: 400: Invalid query - invalid"

Any thoughts? 

Omar Hamzeh

unread,
Sep 14, 2023, 6:49:24 AM9/14/23
to GAM for Google Workspace
Hi Ross
hope you're doing well 

Is it possible to Delete all files that don’t have a specific Label and haven’t been viewed in the last 6 months and before a specific creation date??

Regards
Reply all
Reply to author
Forward
0 new messages