Skip to main content

I am trying to create a zap to file documents into different folders on Google Drive, however I am stuck at selecting and creating the right folder structure.

 

Let’s say I want to store the file in documents/client1/uploads

And assume I also want folders for other clients like documents/client2/uploads, documents/client3/uploads and also could have other folders, for instance documents/client1/processed

 

The problem is, that I don’t know if any of these folders exist, so ideally, I would like to find or create ‘documents/clients1/uploads’

I have tried to add a looping step and splitting the folder on / . So I have a loop iteration for documents, client1 and uploads. In each I can find or create the folder, but for this to work, one loop, would need to know the result of the previous loop to set its parent folder, which I don’t think it possible.

 

Are there other ways I can tackle this?

Hi @PeterB 

Try using these successive Zap actions steps:

  • Action: GDrive - Find Folder
    • Enable to create Folder if not found
    • e.g. Folder Name: documents
  • Action: GDrive - Find Folder
    • Enable to create Folder if not found
    • For the Parent Folder, map the ID of the Folder from the previous step
    • e.g. Folder Name: client 1
  • Action: GDrive - Find Folder
    • Enable to create Folder if not found
    • For the Parent Folder, map the ID of the Folder from the previous step
    • e.g. Folder Name: uploads

Thanks @Troy Tessalone! That will work for sure and I will probably end up doing it like that.

I would have preferred a more generic way.

The path comes from an external system and next month, we may add an extra level, eg documents/client1/uploads/project1

I think I may get it to work with a recursive sub-zap, but I got lost trying to extract “documents” and “client1/uploads/project1” from the initial path. I may give it another try tomorrow.

Best, Peter


@PeterB 

Zap action: Formatter > Text > Split

Split by: /

Output: all as separate fields


@Troy Tessalone 

Yes, getting the first element is easy, but how do you get all but the first if you don’t know how many elements there are?

I can use a Formatter to get to the first element “documents”, but how can I get all the remaining elements? I either need to put all remaining elements in one string, like “client1/uploads/project1” or I need the line items with the first one removed. It looks like I may need a code node for that, but I am pretty new to Zapier, so I may be missing an already existing app/tool.

 

 


@PeterB

In the Formatter step, for the Segment Index, select: All (as separate fields).