Creating Google Drive folders and subfolder based on categories from AI

I want to automate file storage with n8n and Google Drive. My use case is that I scan documents as PDF files with my scanner and upload them directly to Google Drive. Afterwards, the file should be converted to JPG with Stirling PDF for further processing by Gemini and renamed based on criteria (Date_InvoiceIssuer). This works well so far. What’s missing now is the automatic creation of missing folders in Google Drive (if they don’t already exist) and then moving the file to the appropriate folder. The file structure should be: Year (invoice date) as the main folder and Category (determined by Gemini) as a subfolder

I’m having trouble getting this to work, could someone help?

Information on your n8n setup

  • **n8n version: 1.72.1
  • **Database (default: SQLite): SQLite
  • **Running n8n via (Docker, npm, n8n cloud, desktop app): npm
  • **Operating system: Debian 12

Hey @Coven82, what particular problem are you having? I see your workflow, and it looks like the right approach. But if you need to create a subfolder, just use another node to create it after the actual folder has been created.

The first problem is that I can’t convert the date from the invoice date that Gemini analyzes into the format YYYY for the folder creation process. The second problem is that the workflow with the folder and subfolders, which should be created based on the information (if not if already exists) from Gemini, is not working. The file will be moved in the root directory

For the first problem - is it always the same format coming out? If yes can you share it?
For the second problem I’ve shared the solution above.

Did you get this solved? I have same kind of challenges creating folders depending on the data.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.