Most efficient command to find million+ files containing text in filename for specific user?

29 views
Skip to first unread message

HankH

unread,
Jan 30, 2026, 10:20:27 AM (3 days ago) Jan 30
to GAM for Google Workspace
User has over a million files with a certain text in the filename "sample".

What's the most efficient way to get a text file list of all these files and then to delete them after review?

I found some commands on the cheatsheet but they are both taking an exceptionally longtime to generate. 30+ minutes.

My first try is this:

gam user myu...@mydomain.tld print filelist query "title contains 'sample'" > filelist.txt

My second try is this:

gam user myu...@mydomain.tld show fileinfo root id title
Drive Folder: My Drive (XXXXX)
    id: YYYYYYYYYYY
gam user myu...@mydomain.tld print filelist query "'YYYYYYYYY' in parents and title contains 'sample'" id name > filelistwithparentid.txt

Ross Scroggs

unread,
Jan 30, 2026, 11:10:52 AM (3 days ago) Jan 30
to google-ap...@googlegroups.com
This is best if the files are all over the My Drive

gam user myu...@mydomain.tld print filelist query "title contains 'sample'" fields id,name > filelist.txt

This only works if all of the files are directly in the root of the My Drive.
gam user myu...@mydomain.tld print filelist query "'YYYYYYYYY' in parents and title contains 'sample'" fields id,name > filelistwithparentid.txt

Google returns data for 500-1000 files at a time, yes this will take a long time.

Ross

----
Ross Scroggs



--
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 visit https://groups.google.com/d/msgid/google-apps-manager/b7600f76-c6e0-4528-9759-9c211d552b5fn%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages