Skip to main content

Hi!

I'm working on an automation to process multiple files from a Google Drive folder and need guidance on the best approach. Here's my complete workflow goal and current progress:

📋 Complete Workflow Goal:

  1. Find all files in a specific Google Drive folder (mix of .txt files and other file types)
  2. Extract text content from .txt files only
  3. Combine all text content into one block for AI analysis
  4. Move ALL files (including non-text files) to a different folder after processing

✅ Planned Working Steps:

  1. Schedule by Zapier - to trigger automation for accumulated files once a week
  2. Google Drive - Find Files - search for those with mime type text/plain
  3. Looping by Zapier - iterate through each file ID

From this part on, I’m not really sure which is the best next course of action to take:

My plan is to find a way to download each file id via Webhooks → Use Transform to combine all those texts → Run them through AI for analysis → then move all those txt files, including those non txt files into a different folder (to ensure they won’t be reprocess once again).

 

❓ Key Questions & Challenges:

1. File Content Aggregation:

  • How do I combine all individual file contents into one text block after the loop?
  • All actions seem to stay within the loop - is there a way to aggregate outside the loop?
  • Should I use a different approach than looping for this use case?

2. File Type Handling:

  • My folder contains both .txt files and other file types (.pdf, .docx, etc.)
  • I only want to extract text from .txt files, but move ALL files afterward
  • Should I filter file types within the loop or handle this differently?

3. File Movement:

  • After processing, I need to move ALL original files to a "processed" folder
  • Should this happen within the loop (move each file individually) or in a batch after processing?

I'm a bit confused after Working Step 3, since I think all actions seem to stay within the loop, and our goal is to combine all those files altogether... Seem to be lost for a moment here…

 

Any recommendation on the best workflow to follow for this? Is looping the right approach? Thanks in advance for your comments and suggestions. :)


NOTE: It’s my first time, so I’m not sure if the first one I posted was really posted at all… this might come off as a duplicate, so I apologize if it turns out that way).

Hi ​@phosphere, here’s how I would attempt this:

 

The first step after your trigger would be to retrieve the .txt files from the specified GDrive folder - just modify the folder ID in my screenshot to the ID of your parent folder.

 

I would then Loop over the FIle IDs returned by that step:

And then run a Retrieve File by ID for each iteration of the loop. This will return a File (exists but not shown) object that you can use in a subsequent step.

 

Add a Files → Text from File step to extract the contents of each .txt file:

 

Next, since you want to continue looping through all the .txt files, and combine them into a single text chunk, you can use the Digest by Zapier → Append Entry and Schedule Digest action. This will just keep appending the text of each new file to the text of all the preceding files. Make sure you set Frequency to Manual, so that it will only “release” the digest once you’re done with the last loop iteraiton.

 

Next, add a Filter step that will only continue when Loop Iteration Is Last = TRUE, The steps after this filter will only run when all the loop iterations have finished running. 

 

After that Filter, add a Digest by Zapier → Release Existing Digest step, which should release the final combined text file

You can take the output of this and pass it to the AI by Zapier step for analysis, and then finally add a step that moves the file to the other folder.

For moving all the non-text files to the other folder, I would just clone this Zap once it’s working, modify step 2 so that it only returns files that are not .txt, and then have it loop through and move those. So you can eliminate all the intermediate steps, as the only thing you’ll want to do inside this loop is to move the file.

 

Hope this helps!


I’ll try and set it up now, then will return here if something doesn’t work. Thanks so much for a very detailed response, and I also found out now that it’s possible to exit a Loop as well. Thank you so much! :)


Hi ​@phosphere,

 

Just keep us posted so we can assist you further if needed. Thank you.