This script is designed to monitor specified Google Drive folders for new file additions and send email notifications upon detecting any changes. The complete code can be found in my GitHub repository at Net-RVA's GitHub, which provides a detailed script for automating your Google Drive to send email alerts for new files.
This array, watchedFolders
, contains objects defining the Google Drive folders you want to keep an eye on. Each object includes the type of resource (resourceType
), a friendly name for identification (resourceName
), and the unique ID of the folder (resourceId
).
The persistentStore
variable initializes the Object Store library for data storage, ensuring that file counts within each folder are tracked over time. The manual: true
option indicates that the data will be saved explicitly using the persist()
method.
monitorFolders
is the core function that iterates through each folder defined in watchedFolders
, checks for new files, and sends an email alert if any are found. It uses fetchResource
to access the folder and compares the current file count with the stored count. If there's a difference, an email is sent, and the new count is updated in the store.
The initializeFolderInStore
function sets up a new folder in the persistentStore
with an initial file count of 0, preparing it for monitoring.
fetchResource
retrieves the Google Drive resource (folder or file) based on its ID and type, allowing the script to access and monitor these resources.
This script automates the monitoring of Google Drive folders for new files, sending email notifications when changes are detected. For the full code and more details, visit the GitHub repository provided above. This script offers a practical solution for staying updated on file additions to your Google Drive folders, enhancing productivity and collaboration.