List Files Older than X Days

213 views
Skip to first unread message

Kevin Apodaca

unread,
Oct 17, 2023, 3:30:59 PM10/17/23
to GAM for Google Workspace
Hey folks, 

 I have an apps scrip that does this and would like to confirm the right command in gam adv

I want to get a list of all files (docs/sheets/slides) that have not been modified in X days. I have seen this example for 90 days and csv and it is the only reference in the docs to querytime parameter.

As an example, in Drive I can see a .jpeg file that was lastModified July 29th 2021, I want this file to be printed after I run my query, I am attempting using this command

gam user <User Email Address> print filelist querytime1045d -1045d query "mimeType = 'image/jpeg' and lastModified < '#queryTime1045d#'" fields id,name,createdtime,modifiedtime

but have been getting invalid query errors

the 1045d I figured days from July 29th 2021 - Today 

and the query lastModified is just a shot in the dark, also tried with modifiedtime

Any pointers would be super helpful, thank you in advance!

Kevin Apodaca

unread,
Oct 17, 2023, 3:50:07 PM10/17/23
to GAM for Google Workspace
Came across this message with a similar use case but unfortunately no response
https://groups.google.com/g/google-apps-manager/c/1xkmOmG8YMk/m/f6VKEoalEAAJ

Will try some of the suggestions found here

Ross Scroggs

unread,
Oct 17, 2023, 3:52:43 PM10/17/23
to google-ap...@googlegroups.com
Kevin,


gam user <User Email Address> print filelist querytime1045d -1045d query "mimeType = 'image/jpeg' and modifiedTime < '#queryTime1045d#'" fields id,name,createdtime,modifiedtime

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 on the web visit https://groups.google.com/d/msgid/google-apps-manager/ad9b3f97-b2ce-47d9-ad83-9041c63a4b1en%40googlegroups.com.

Kevin Apodaca

unread,
Oct 17, 2023, 4:18:55 PM10/17/23
to GAM for Google Workspace
Oh that is a great link!

This seems to do what I need

gam user <user email> print filelist query "modifiedTime < '2022-12-01T12:00:00'" 

and can just add an additional filter for the file type 

gam user <user email> print filelist query "mimeType = 'image/jpeg' and modifiedTime < '2022-12-01T12:00:00'"

Thanks!
Reply all
Reply to author
Forward
0 new messages