How to automatically organize and upload PDF attachments into specific folders?

  • 23 March 2022
  • 5 replies
How to automatically organize and upload PDF attachments into specific folders?
Userlevel 7
Badge +11
  • Community Manager
  • 5376 replies
Hey friends! This week I’m going to talk about how to create a Zap that will take PDF attachments received in Gmail and upload them into the relevant client folder in Google Drive. This guide specifically talks about how to to this with Gmail and Google Drive, but you can apply the same principles to other similar apps too!
We’ll cover how to take specific PDF file attachments, create a new folder (if one doesn’t already exist) for them in Google Drive, upload the file to that folder. We’ll also get the Zap to send out an email to the client thanking them for sending us the file.

You can download a copy of the Zap template for this workflow here:
Upload PDFs into client's Google Drive folder and send email autoresponder

Setting up the trigger

First up we’ll need to set up the trigger that runs when a new attachment is received in Gmail. To do that we’ll want to select the New Attachment trigger for Gmail. This will trigger the Zap separately for each attachment added to an email.
In the Search String section you’ll want to set up a relevant query to ensure your Zap is only triggering for the right types of emails. For example if I only wanted to trigger for new emails in my inbox emails with the subject line “artwork” then I’d set it up like so:

💡 TIP: Make sure you specify the mailbox for the Label/Mailbox field. I say this as the Sent items folder will also be checked by the trigger step and we won’t want to create an accidental Zap Loop when we send out the auto responder email to the customer later on!

Setting up a Filter

As I’m only wanting to upload PDFs I’m going to add a Filter step use the condition (Text) Contains pdf to ensure that only an attachment with a Mime Type of application/pdf will be uploaded:

Extracting the client name

Now that the Filter is added, let’s keep things super organised by creating a new folder specific to this client (if there isn’t one for them already!). But wait, how do we know what client it is from the email? 
Well in most cases the client name is the same as their email domain name so you can use a Formatter (Text > Extract Pattern) step to extract the domain name. You can learn more about using Regex to find and extract text here: Find text with regular expressions in Zaps

If you’re not familiar with Regex that’s ok, you’ll just need to add @(\w+) to the Pattern field to extract the word (domain) that appears right after the @ symbol:
When we test the step it would then output the word “zapier”. So regardless of what the client's email address is or whether it ends in .com, .org, .uk etc we should be able to always extract the domain name from it. Cool right? 

Find/create the folder

Next, you’ll add a Find a Folder action for Google Drive and select the output from the previous formatter step for the Folder Name field. Choose the relevant Drive and Parent Folder as necessary: 
Note that under the Parent Folder field, there’s the option to Create Google Drive Folder if it doesn’t exist yet?. You’ll want to make sure that’s selected so that the Zap can automatically add a new folder!

Upload the File

Now let’s add an Upload File action and choose the Custom value option on the Folder field. Select the ID number for the folder that was found/created by the previous step.
Next, select the Attachment field from the Gmail trigger step that contains the file: 
659cf547e7fd5a312a1808f710568042.pngTest the step to ensure that will upload the file correctly. I’d also recommend heading over to Google Drive to make sure it definitely worked as expected:
e6fb1c1204dca3086439744d8389a14d.pngYay, it worked! 🎉

Set up an autoresponder email

Now, our clients will want us to let them know that we got their really important file, but we’re super busy and don’t have time to respond to every email. So let’s send them an automated email to say thanks and let them know that we’re on it.
To do that we’ll use Gmail’s Send Email action and select the clients email address and name from the Gmail trigger step. In the From field select the email address or alias you want the email to be sent from. Set a From Name and add the message for the email into the Body field:
In the above example, I’ve chosen to sent the email as Plain text. But if you select html for the Body Type field you can then include HTML tags in your message. But it’s important to note that not all tags are supported. 

You can find out more about the HTML tags that Gmail supports here: What HTML tags are supported in Gmail?
💡TIP: If you’ve got any VIP clients you’d prefer to send out a more personalised email response to manually, a Filter step can be used to check that the sender of the email doesn’t contain their email address. 
And if you want to get really fancy, you could use Paths to add some conditional logic to your Zap to carry out different actions based on whether the client is a VIP or not. For example if the sender is a VIP you could get the Zap to send you an urgent SMS to let you know that a VIP client needs a response ASAP.

Wrapping up

If you made it this far, thanks for reading! Don’t stop at just organising uploads into client specific folders and sending out an email? You could add in a Send Direct Message Slack action to alert you when a new file has been uploaded. Or you could create a client-specific Google Sheet spreadsheet instead and add a new spreadsheet row to log details from the email so you can keep a record of everything that’s been received. The possibilities are endless!
I do hope you find this useful and that it inspires you to create lots more time-saving Zaps. 

Happy Zapping! ⚡

5 replies

Userlevel 1


Thanks for this info it has been useful. 

im trying to make it so that when an email with multiple attachments of different file types is received only the pdf attachment is uploaded to Drive, but I’ve not managed to make it work.  

 any tips gratefully received. 





Thanks! Is it possible to upload only few pages of the pdf and not the whole pdf?

Userlevel 7
Badge +11

Hi @Ed AGR and @KD2520! 👋

@Ed AGR - I’m so sorry to have missed your message here previously! Were you since able to get it resolved? If not, can you share some screenshots (please remove/hide any private information like names, emails etc) showing the set up of any actions in the Zap that aren’t working as expected as I’ll be happy to assist further! 

@KD2520 - I’ve not used it but I know that the PDF4me app on Zapier has an Extract Pages From PDF action. Perhaps you could use that to extract the desired pages from the PDF and upload them? You can see a full list of all the document related apps on Zapier here:

Hope that helps! 🙂 

Userlevel 1

Hi, no I did not manage to resolve this but found a free way to do it, as I did with other automations I wanted. This zap got stuck in a loop, despite me pausing it, uploaded the same file several hundred times and ate all my credit. 


In the end I cancelled my Zapier account at renewal as it was not working for me. 





Userlevel 7
Badge +11

Really sorry to hear that @Ed AGR, but totally understand. If you ever change your mind and want to give Zapier another try, please do reach out to us in the Community again if you run into any issues or questions and we’ll be happy to help! 

For anyone that comes across this thread and is also running into a Zap loop: please check out our Zap is stuck in a loop guide which has some advice on how to avoid Zap loops. And if you’ve had any unexpected task usage due to an accidental Zap loop please get in touch with our Support team here who will be happy to assist further. 🙂