I need a script to monitor a specific Google Drive folder whenever there is a change and notify me by email
email, google-apps-script, google-drive-realtime-api, monitor
Solution
The file monitoring code at that link, is an Apps Script bound to a Sheet. An Apps Script can be bound to a Sheet, Doc, Form or Site. An Apps Script can also be a `stand alone` application. So, any code you may want to write, does not need to be in a spreadsheet.
An Apps Script can be set up to have a `Time-driven` event trigger.
There is also a `Script Service` to build Clock Triggers.
ClockTriggerBuilder Class
Using Time Driven Event Trigger, or a Clock Trigger you could use the `getSize()` method to return the amount of disk space used by the item:
Class - Folder - getSize Method
// This example logs the first file's size in bytes
// Note: This can also be used on a folder to get the size of its contents
var file = DocsList.getAllFiles[0];
Logger.log(file.getSize());
Of course, you would need to know what the original size of the folder or file was, and so you would need to store the current size somewhere. You could create a file for storing that information, or use the built in database that Apps Script has.
For storing your historical folder or file information you could use `ScriptDB`.
ScriptDB
Quote:
ScriptDB is a JavaScript object database for Google Apps Script. Each script project gets a database, which the script can use to save, update, and search JavaScript object data.
You could write historical file and folder info to a spreadsheet or document also.
Depending on who owns the file, and who is accessing the file, permissions would need to be granted, or you'd need to use `oAuth2` to authenticate who has access to the file and folder information.
If you can't write all the code yourself, you could set up a shared Apps Script file, or find some other way to have people collaborate on the project.
Problem
I have been trying all day and I found this: http://www.jellybend.com/2012/12/19/monitor-google-drive-folders-with-google-apps-script/ The attached script worked only partially for me. It doesn't respond to change to the subfolders even there are files inside the subfolders (eg. rename/delete the subfolder). It also seems to have errors if I delete and re-add the same file to the folder again, it just doesn't email me for the newly added "old file". I also found this: https://developers.google.com/drive/v2/reference/changes/list#examples but unfortunately I am not really sure what those parameters are and I am just inexperienced in writing something like that. Any help will be greatly appreciated! Thanks!