I've seen some helpful answers to this question, but none that have the script specify to list only new files/folders added to the parent folder listed. I think what I'm trying to do is combine this from user Tedinoz:
https://webapps.stackexchange.com/a/121447/250578 and this
https://gist.github.com/wdziemia/c45a59d13510fcd2f273f8e0583cb8d9 (except not for email notification).
Is there an easy modification to Tedinoz's code to only find files added within the last 24 hours (for example)? I do not want to list files that already exist.
Best Answer
You want to list GDrive files that are recently created, either "today" or within a time span that you decide. Your existing script doesn't include a value for the date that a created was created.
I suggest that there are two options, both of which include adding
dateCreated()
to the information obtained via the script.Option#1 - Date comparison within the script.
Option#2 - Date filter/query with a spreadsheet.
Of the two, I suggest that the second is more flexible, but this is a matter of opinion.
Script: with Date Comparison
Personally I don't prefer this option because you you can't see what files were NOT selected.
Note:
var foldername = "<<Enter your folder name>>";
- enter your own Google Drive folder namevar sheetname = "<<Enter your output sheet name>>";
- enter the name of the sheet where the data will output. not the name of the spreadsheet, just the name of the sheet in the spreadsheetScript: List all files, then Date Comparison within by query/filter
Note:
var foldername = "<<Enter your folder name>>";
- enter your own Google Drive folder namevar sheetname = "<<Enter your output sheet name>>";
- enter the name of the sheet where the data will output. not the name of the spreadsheet, just the name of the sheet in the spreadsheetQuery:
=query(allfiles!A1:I,"select A, B, C,I where C >= date '"&TEXT(B3,"yyyy-mm-dd")&"' and C <= date '"&TEXT(B1,"yyyy-mm-dd")&"'")
End Day: Cell B1:
=today()
Days Ago: Cell B2: 7 (as in a "week")
Start Day: Cell B3:
=B1-B2