Monitor a Google Drive folder for new files and send an email notification.
- Automatically detects new files in a Google Drive folder.
- Sends an email notification to specified recipients whenever a new file is detected.
- Downloads the new file from Google Drive and saves it locally (can delete local file after handling).
- Supports multiple email notification handlers.
- Python 3.10 or later
- A Google Cloud Platform project with the Drive API enabled
- A service account key file (credentials.json)
- Clone this repository:
$ git clone https://github.com/ryangregorydev/google-drive-folder-monitor.git
- Install the required Python packages using pip:
$ pip install -r requirements.txt
-
Create a new project and a new service account key file in Google Cloud Platform (GCP) and store it somewhere on your disk.
-
Create and configure you
.env
file:
$ touch .env
# .env file example content
CREDENTIALS_FILE=<path to your service account key file>
DRIVE_FOLDER_ID=<your Google Drive folder ID>
POLL_INTERVAL=60
GMAIL_EMAIL=example@gmail.com
GMAIL_PASSWORD=xxxxxxxxxx
EMAIL_TO=targetemail@example.com,targetemail2@example.com
If you have MFA activated on your Google account, you will need to create a app password and add it to your .env file.
- Run the script:
$ python main.py