selectively deleting old files and empty folders

108 views
Skip to first unread message

Temple Rodgers

unread,
Mar 4, 2021, 9:43:12 AM3/4/21
to GAM for Google Workspace
hi everyone,
I have migrated tens of thousands of files to Google Workspace and I want to check how I can delete all files older than a certain date plus, if the folder is left empty, the folder too.
Is that possible?
I was tinkering with listing the files to a spreadsheet then trying to filter and running gam csv to delete files, but it's difficult identify the folders and whether or not they may have a file left in there.
T

Temple Rodgers

unread,
Mar 4, 2021, 9:53:25 AM3/4/21
to GAM for Google Workspace
ah, I've found how to delete empty folders gam <UserTypeEntity> delete emptydrivefolders <TeamDriveEntity>

Brian Kim

unread,
Mar 4, 2021, 10:20:58 AM3/4/21
to GAM for Google Workspace
gam user username print filelist query "modifiedTime < '2021-01-01T12:00:00'" 

Temple Rodgers

unread,
Mar 4, 2021, 10:51:50 AM3/4/21
to GAM for Google Workspace
thank you @the.br... that's great and works like a charm.  I really like GAM!
For test purposes, i created some empty folders in a file hierarchy on a shared drive and ran gam <usertypeentity> delete emptydrivefolders but it didn't delete them.  Why would that be so?

Ross Scroggs

unread,
Mar 4, 2021, 10:53:58 AM3/4/21
to google-ap...@googlegroups.com
Temple,

Show: gam version

Ross


Disclaimers apply, for full details see: https://hackney.gov.uk/email-disclaimer


--
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/77d397d3-44d2-4665-9b88-264536ec701an%40googlegroups.com.


--

Temple Rodgers

unread,
Mar 4, 2021, 10:56:05 AM3/4/21
to GAM for Google Workspace
GAMADV-XTD3 5.31.22 - https://github.com/taers232c/GAMADV-XTD3 - pyinstaller
Ross Scroggs <ross.......@gmail.com>
Python 3.9.1 64-bit final
google-api-python-client 1.9.3
httplib2 0.18.1
Linux Neon 20.04 Focal x86_64

Ross Scroggs

unread,
Mar 4, 2021, 10:58:18 AM3/4/21
to google-ap...@googlegroups.com

Temple Rodgers

unread,
Mar 4, 2021, 11:05:11 AM3/4/21
to GAM for Google Workspace
thank you Ross - that's worked this time.
so it looks like a two-pass process, first delete the files and then the empty folders.
brilliant responses from the group!

Brian Kim

unread,
Mar 4, 2021, 11:15:21 AM3/4/21
to GAM for Google Workspace
Actually, you may want to exclude folders from your first pass.

gam user username print filelist query "modifiedTime < '2021-01-01T12:00:00'" showmimetype not gfolder

Temple Rodgers

unread,
Mar 4, 2021, 11:52:13 AM3/4/21
to GAM for Google Workspace
yes!  Exactly what I wanted! ... there's so many "decorations"!!!
Reply all
Reply to author
Forward
0 new messages