DIY: How CPG Supply Chain Teams Can Automatically Organize Vendor Attachments from Gmail to Google Drive + Google Sheets

DIY: How CPG Supply Chain Teams Can Automatically Organize Vendor Attachments from Gmail to Google Drive + Google Sheets

DIY: How CPG Supply Chain Teams Can Automatically Organize Vendor Attachments from Gmail to Google Drive + Google Sheets

Jan 2, 2026

Create a Gmail filter by clicking the filter icon on the top search bar, and adding your filter criteria.

Are vendor emails piling up with no system to track critical docs?

If your ops team is spending hours manually downloading PDFs, renaming files, and saving invoices, contracts, or BOLs into the right folders, there’s a better way.

This guide will show you how fast-growing CPG brands are using a simple Google Apps Script we created to:

  • Auto-save labeled Gmail attachments into structured Drive folders

  • Rename and organize files by vendor, label, and date

  • Maintain a Google Sheet dashboard with full traceability

it'll save your documents to Google Drive in neatly-arranged folders, every 15 minutes.

Why This Matters for Supply Chain

When you're working with co-packers, 3PLs, and raw material vendors, staying organized is essential. Visibility depends on having timely access to:

  • Signed contracts

  • Inbound BOLs or receiving documents

  • Vendor invoices or COAs

  • Shipping confirmations

Often, those documents are buried in email threads. This workflow ensures every important PDF is renamed, categorized, and logged, without your team touching a thing.

Use Cases for CPG Supply Chain Teams

  • Auto-log vendor invoices for monthly close

  • Track shipment docs like BOLs from 3PLs or carriers

  • Archive contract attachments from new copackers or service providers

  • Maintain documentation for each raw material or packaging supplier

All this lives in Drive + Sheets, where your team is already working.

Benefits

  • Eliminate manual file saving

  • Never misplace vendor docs again

  • Cut down on ops back-and-forth

  • Give finance a reliable audit trail

  • Scale documentation as your team grows

How It Works

The Setup

  1. You label an email as Contracts or Receipts in Gmail. You can use Gmail's filters to automatically label emails with certain criteria with a label. Here's a quick tutorial to do so. For example, if an email comes from your co-packer's URL, has a PDF attachment, and has "BOL" in the body or in the subject, you can set up an automated filter to label it as BOL.

  2. Every 15 minutes, a script checks for those labels.

  3. If a PDF is found:

    • It’s renamed: [VendorName]_[Label]_[Date].pdf

    • It’s saved to a Drive folder like: /Receipts/VendorXYZ/

    • A row is added to your Sheet log for tracking

The Result

A fully searchable dashboard + folder system your team can rely on.

What You’ll Need

  • A Gmail account (with two labels: Contracts, Receipts to start — once you get the hang of it, you can add more and edit the script yourself)

  • A Google Drive folder structure:

    • Automated Attachments

      • /Contracts/

      • /Receipts/

  • A new Google Sheet for the dashboard

  • A copy/paste Apps Script (we give you this below!)

You do not need third-party tools, API keys, or any coding knowledge.

We provide the code below, which you just need to copy and paste, and we take advantage of native Google Workspace automation, which you're likely already paying for.

Folder + Naming Convention

For every email, the script renames the attachment using:

[SenderName]_[LabelName]_[Date].pdf

Smart sender logic:

  • If it’s from a domain like @gmail.com, it uses the sender’s full name

  • If it’s from a custom domain like @vendorco.com, it uses vendorco

Folder paths:

  • Automated Attachments/Contracts/vendorco/

  • Automated Attachments/Receipts/vendorco/

Google Sheet Log Example

Each time the script runs, it logs a new row with these data points:

Timestamp

Sender Name

Email

Subject

Original File

Renamed File

Label

Email Link

Drive Link

This dashboard acts like a real-time audit trail, which is searchable, shareable, and exportable to finance, ops, or external partners.

Go ahead and add these column headers to the first row of your Google Sheet.

Manual or Automated

  • The script runs automatically every 15 minutes

  • But you can also add a “Run Now” button to your Google Sheet if you want an instant refresh

How to Set It Up (In Under 30 Minutes)

Step 1: Create Your Gmail Labels

  • Contracts

  • Receipts

If you have rules to create automated filters, then set up those filters so that Gmail auto-labels emails that fit the criteria.

Step 2: Set Up Your Drive Folder

  • Main folder: Automated Attachments

    • Subfolders: Contracts, Receipts

Step 3: Open a New Google Sheet

  • Name it Attachment Log

  • Add these headers in Row 1:

Timestamp | Sender Name | Sender Email | Email Subject | Original File Name | Renamed File Name | Date of Email | Label | Email Link | Drive File Link

Step 4: Paste the Google Apps Script

  1. In the Google Sheet, click Extensions → Apps Script

  2. Paste the full script from this Gist

  3. Update the MAIN_FOLDER_ID in the code that you've pasted with your Drive folder ID. On an example URL like https://drive.google.com/drive/u/2/folders/1421hjkdysag9dsyfad , your Drive folder ID is 1421hjkdysag9dsyfad

Step 5: Add the Time-Based Trigger

  1. In the Apps Script editor, click Triggers (clock icon on left).

  2. Click + Add Trigger.

    • Function: main

    • Event source: Time-driven

    • Type: Minutes timer

    • Interval: Every 15 minutes

Step 6: Test it

  1. Label a Gmail message with a PDF attachment using either "Contracts" or "Receipts".

  2. Open the Sheet → Attachment Bot menu option → Run Now

  3. Check:

    • Drive folders for saved PDF

    • Sheet for a new row with details

AI-Assisted Troubleshooting

Stuck on one of these steps? Ask AI.

Open up a ChatGPT window and copy and paste this full tutorial, along with the code in the linked Gist, as context.

Describe what you're trying to do, and where you're stuck. If you're getting error messages, paste those into the chat as well.


TL;DR

  • Automatically save PDF attachments from Gmail to Google Drive

  • Rename them based on vendor, label, and date

  • Organize them into folders by label and sender

  • Log every step into a Google Sheet dashboard

  • No third-party apps. Just Gmail, Drive, and Apps Script

Want Us to Install This For You?

We help CPG ops teams automate manual workflows like this one, and any other workflows that they can think of. If you want us to set this up (or build a more advanced version), book a quick call.

Are vendor emails piling up with no system to track critical docs?

If your ops team is spending hours manually downloading PDFs, renaming files, and saving invoices, contracts, or BOLs into the right folders, there’s a better way.

This guide will show you how fast-growing CPG brands are using a simple Google Apps Script we created to:

  • Auto-save labeled Gmail attachments into structured Drive folders

  • Rename and organize files by vendor, label, and date

  • Maintain a Google Sheet dashboard with full traceability

it'll save your documents to Google Drive in neatly-arranged folders, every 15 minutes.

Why This Matters for Supply Chain

When you're working with co-packers, 3PLs, and raw material vendors, staying organized is essential. Visibility depends on having timely access to:

  • Signed contracts

  • Inbound BOLs or receiving documents

  • Vendor invoices or COAs

  • Shipping confirmations

Often, those documents are buried in email threads. This workflow ensures every important PDF is renamed, categorized, and logged, without your team touching a thing.

Use Cases for CPG Supply Chain Teams

  • Auto-log vendor invoices for monthly close

  • Track shipment docs like BOLs from 3PLs or carriers

  • Archive contract attachments from new copackers or service providers

  • Maintain documentation for each raw material or packaging supplier

All this lives in Drive + Sheets, where your team is already working.

Benefits

  • Eliminate manual file saving

  • Never misplace vendor docs again

  • Cut down on ops back-and-forth

  • Give finance a reliable audit trail

  • Scale documentation as your team grows

How It Works

The Setup

  1. You label an email as Contracts or Receipts in Gmail. You can use Gmail's filters to automatically label emails with certain criteria with a label. Here's a quick tutorial to do so. For example, if an email comes from your co-packer's URL, has a PDF attachment, and has "BOL" in the body or in the subject, you can set up an automated filter to label it as BOL.

  2. Every 15 minutes, a script checks for those labels.

  3. If a PDF is found:

    • It’s renamed: [VendorName]_[Label]_[Date].pdf

    • It’s saved to a Drive folder like: /Receipts/VendorXYZ/

    • A row is added to your Sheet log for tracking

The Result

A fully searchable dashboard + folder system your team can rely on.

What You’ll Need

  • A Gmail account (with two labels: Contracts, Receipts to start — once you get the hang of it, you can add more and edit the script yourself)

  • A Google Drive folder structure:

    • Automated Attachments

      • /Contracts/

      • /Receipts/

  • A new Google Sheet for the dashboard

  • A copy/paste Apps Script (we give you this below!)

You do not need third-party tools, API keys, or any coding knowledge.

We provide the code below, which you just need to copy and paste, and we take advantage of native Google Workspace automation, which you're likely already paying for.

Folder + Naming Convention

For every email, the script renames the attachment using:

[SenderName]_[LabelName]_[Date].pdf

Smart sender logic:

  • If it’s from a domain like @gmail.com, it uses the sender’s full name

  • If it’s from a custom domain like @vendorco.com, it uses vendorco

Folder paths:

  • Automated Attachments/Contracts/vendorco/

  • Automated Attachments/Receipts/vendorco/

Google Sheet Log Example

Each time the script runs, it logs a new row with these data points:

Timestamp

Sender Name

Email

Subject

Original File

Renamed File

Label

Email Link

Drive Link

This dashboard acts like a real-time audit trail, which is searchable, shareable, and exportable to finance, ops, or external partners.

Go ahead and add these column headers to the first row of your Google Sheet.

Manual or Automated

  • The script runs automatically every 15 minutes

  • But you can also add a “Run Now” button to your Google Sheet if you want an instant refresh

How to Set It Up (In Under 30 Minutes)

Step 1: Create Your Gmail Labels

  • Contracts

  • Receipts

If you have rules to create automated filters, then set up those filters so that Gmail auto-labels emails that fit the criteria.

Step 2: Set Up Your Drive Folder

  • Main folder: Automated Attachments

    • Subfolders: Contracts, Receipts

Step 3: Open a New Google Sheet

  • Name it Attachment Log

  • Add these headers in Row 1:

Timestamp | Sender Name | Sender Email | Email Subject | Original File Name | Renamed File Name | Date of Email | Label | Email Link | Drive File Link

Step 4: Paste the Google Apps Script

  1. In the Google Sheet, click Extensions → Apps Script

  2. Paste the full script from this Gist

  3. Update the MAIN_FOLDER_ID in the code that you've pasted with your Drive folder ID. On an example URL like https://drive.google.com/drive/u/2/folders/1421hjkdysag9dsyfad , your Drive folder ID is 1421hjkdysag9dsyfad

Step 5: Add the Time-Based Trigger

  1. In the Apps Script editor, click Triggers (clock icon on left).

  2. Click + Add Trigger.

    • Function: main

    • Event source: Time-driven

    • Type: Minutes timer

    • Interval: Every 15 minutes

Step 6: Test it

  1. Label a Gmail message with a PDF attachment using either "Contracts" or "Receipts".

  2. Open the Sheet → Attachment Bot menu option → Run Now

  3. Check:

    • Drive folders for saved PDF

    • Sheet for a new row with details

AI-Assisted Troubleshooting

Stuck on one of these steps? Ask AI.

Open up a ChatGPT window and copy and paste this full tutorial, along with the code in the linked Gist, as context.

Describe what you're trying to do, and where you're stuck. If you're getting error messages, paste those into the chat as well.


TL;DR

  • Automatically save PDF attachments from Gmail to Google Drive

  • Rename them based on vendor, label, and date

  • Organize them into folders by label and sender

  • Log every step into a Google Sheet dashboard

  • No third-party apps. Just Gmail, Drive, and Apps Script

Want Us to Install This For You?

We help CPG ops teams automate manual workflows like this one, and any other workflows that they can think of. If you want us to set this up (or build a more advanced version), book a quick call.

Are vendor emails piling up with no system to track critical docs?

If your ops team is spending hours manually downloading PDFs, renaming files, and saving invoices, contracts, or BOLs into the right folders, there’s a better way.

This guide will show you how fast-growing CPG brands are using a simple Google Apps Script we created to:

  • Auto-save labeled Gmail attachments into structured Drive folders

  • Rename and organize files by vendor, label, and date

  • Maintain a Google Sheet dashboard with full traceability

it'll save your documents to Google Drive in neatly-arranged folders, every 15 minutes.

Why This Matters for Supply Chain

When you're working with co-packers, 3PLs, and raw material vendors, staying organized is essential. Visibility depends on having timely access to:

  • Signed contracts

  • Inbound BOLs or receiving documents

  • Vendor invoices or COAs

  • Shipping confirmations

Often, those documents are buried in email threads. This workflow ensures every important PDF is renamed, categorized, and logged, without your team touching a thing.

Use Cases for CPG Supply Chain Teams

  • Auto-log vendor invoices for monthly close

  • Track shipment docs like BOLs from 3PLs or carriers

  • Archive contract attachments from new copackers or service providers

  • Maintain documentation for each raw material or packaging supplier

All this lives in Drive + Sheets, where your team is already working.

Benefits

  • Eliminate manual file saving

  • Never misplace vendor docs again

  • Cut down on ops back-and-forth

  • Give finance a reliable audit trail

  • Scale documentation as your team grows

How It Works

The Setup

  1. You label an email as Contracts or Receipts in Gmail. You can use Gmail's filters to automatically label emails with certain criteria with a label. Here's a quick tutorial to do so. For example, if an email comes from your co-packer's URL, has a PDF attachment, and has "BOL" in the body or in the subject, you can set up an automated filter to label it as BOL.

  2. Every 15 minutes, a script checks for those labels.

  3. If a PDF is found:

    • It’s renamed: [VendorName]_[Label]_[Date].pdf

    • It’s saved to a Drive folder like: /Receipts/VendorXYZ/

    • A row is added to your Sheet log for tracking

The Result

A fully searchable dashboard + folder system your team can rely on.

What You’ll Need

  • A Gmail account (with two labels: Contracts, Receipts to start — once you get the hang of it, you can add more and edit the script yourself)

  • A Google Drive folder structure:

    • Automated Attachments

      • /Contracts/

      • /Receipts/

  • A new Google Sheet for the dashboard

  • A copy/paste Apps Script (we give you this below!)

You do not need third-party tools, API keys, or any coding knowledge.

We provide the code below, which you just need to copy and paste, and we take advantage of native Google Workspace automation, which you're likely already paying for.

Folder + Naming Convention

For every email, the script renames the attachment using:

[SenderName]_[LabelName]_[Date].pdf

Smart sender logic:

  • If it’s from a domain like @gmail.com, it uses the sender’s full name

  • If it’s from a custom domain like @vendorco.com, it uses vendorco

Folder paths:

  • Automated Attachments/Contracts/vendorco/

  • Automated Attachments/Receipts/vendorco/

Google Sheet Log Example

Each time the script runs, it logs a new row with these data points:

Timestamp

Sender Name

Email

Subject

Original File

Renamed File

Label

Email Link

Drive Link

This dashboard acts like a real-time audit trail, which is searchable, shareable, and exportable to finance, ops, or external partners.

Go ahead and add these column headers to the first row of your Google Sheet.

Manual or Automated

  • The script runs automatically every 15 minutes

  • But you can also add a “Run Now” button to your Google Sheet if you want an instant refresh

How to Set It Up (In Under 30 Minutes)

Step 1: Create Your Gmail Labels

  • Contracts

  • Receipts

If you have rules to create automated filters, then set up those filters so that Gmail auto-labels emails that fit the criteria.

Step 2: Set Up Your Drive Folder

  • Main folder: Automated Attachments

    • Subfolders: Contracts, Receipts

Step 3: Open a New Google Sheet

  • Name it Attachment Log

  • Add these headers in Row 1:

Timestamp | Sender Name | Sender Email | Email Subject | Original File Name | Renamed File Name | Date of Email | Label | Email Link | Drive File Link

Step 4: Paste the Google Apps Script

  1. In the Google Sheet, click Extensions → Apps Script

  2. Paste the full script from this Gist

  3. Update the MAIN_FOLDER_ID in the code that you've pasted with your Drive folder ID. On an example URL like https://drive.google.com/drive/u/2/folders/1421hjkdysag9dsyfad , your Drive folder ID is 1421hjkdysag9dsyfad

Step 5: Add the Time-Based Trigger

  1. In the Apps Script editor, click Triggers (clock icon on left).

  2. Click + Add Trigger.

    • Function: main

    • Event source: Time-driven

    • Type: Minutes timer

    • Interval: Every 15 minutes

Step 6: Test it

  1. Label a Gmail message with a PDF attachment using either "Contracts" or "Receipts".

  2. Open the Sheet → Attachment Bot menu option → Run Now

  3. Check:

    • Drive folders for saved PDF

    • Sheet for a new row with details

AI-Assisted Troubleshooting

Stuck on one of these steps? Ask AI.

Open up a ChatGPT window and copy and paste this full tutorial, along with the code in the linked Gist, as context.

Describe what you're trying to do, and where you're stuck. If you're getting error messages, paste those into the chat as well.


TL;DR

  • Automatically save PDF attachments from Gmail to Google Drive

  • Rename them based on vendor, label, and date

  • Organize them into folders by label and sender

  • Log every step into a Google Sheet dashboard

  • No third-party apps. Just Gmail, Drive, and Apps Script

Want Us to Install This For You?

We help CPG ops teams automate manual workflows like this one, and any other workflows that they can think of. If you want us to set this up (or build a more advanced version), book a quick call.

Sign up for our free newsletter


Get ideas for incorporating the latest in automation and AI in operations, directly to your inbox

Sign up for our free newsletter


Get ideas for incorporating the latest in automation and AI in operations, directly to your inbox

Sign up for our free newsletter


Get ideas for incorporating the latest in automation and AI in operations, directly to your inbox

Crafty Crow

AI agents and workflow automation SaaS for CPG brand Operations teams

Crafty Crow

AI agents and workflow automation SaaS for CPG brand Operations teams

Crafty Crow

AI agents and workflow automation SaaS for CPG brand Operations teams