I have a google drive folder that receives attachments from emails via script and I want to then organize those attachments, which are from many different people, into appropriate sub folders. I'm new to the google apps api and was hoping for some direction.

1 Answer 1


Presumably, somewhere in the script there is logic like this:

var attachments = message.getAttachments();
for (var i = 0; i < attachments.length; i++) {

This saves attachments to the root folder of Google Drive. And you want is to replace it with

var attachments = message.getAttachments();
var folder =  ...      // somehow determine the folder to save to 
for (var i = 0; i < attachments.length; i++) {

so that the attachment is saved to some specific folder. How to determine the folder to save to is up to you.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.