I need help creating a system in Google Sheets that can analyze files stored in my Google Drive folder. Each document has special keywords in its description that start with the @ symbol and are separated by spaces.
My goal is to build a summary report in a spreadsheet that shows statistics for all files in a specific Drive folder. The tricky part is that this folder contains multiple subfolders, and I need to include documents from those nested folders too.
In my spreadsheet, I have already listed all the possible keywords in column A. Now I want column B to automatically display how many files contain each specific keyword in their description.
I believe this requires custom functions or advanced formulas in Google Sheets, but I cannot figure out the right approach. Has anyone solved a similar problem before? What would be the best way to connect Google Sheets with Google Drive file metadata to achieve this automated counting?
just use importrange with a helper sheet that connects to the drive api. way easier than apps script. set up one sheet to pull all file metadata through the drive connector, then use countif formulas in your main sheet for keyword counts. updates automatically and you don’t need any coding.
Had the exact same problem last year with project files scattered across Drive folders. Here’s what actually worked for me: Used Google Apps Script with DriveApp service plus some custom functions in Sheets. The trick is writing a script that searches through all subfolders using getFoldersByName() and getFilesByType(), then pulls description metadata from each file. For the @ keywords, I just used regex to find and count matches. The game-changer was caching results in a separate sheet tab - otherwise you’ll hit API limits every time formulas recalculate. I set the script to run every few hours on a timer trigger to update the cache. Then my main report sheet just references that cache with VLOOKUP or INDEX/MATCH. Biggest pain point? Getting the nested folder structure right. You’ve got to build a recursive function that keeps drilling down into subfolders until it hits every single file. Skip this and you’ll miss files buried in deeper directories. This gives you real-time keyword counts without dealing with external automation tools.
Google Apps Script with custom functions is definitely the way to go, but I skipped the recursive folder scanning approach. Instead of building complex recursive functions, I used the Drive API’s search with “parents in ‘folder_id’” and the “in parents” operator. This automatically searches nested subfolders without manually traversing directories. The breakthrough was creating a custom function that takes your keyword as a parameter and using it directly in spreadsheet cells. In column B, you’d use =COUNTKEYWORD(A2) where A2 has your @ keyword. Inside the function, I used DriveApp.searchFiles() with a query that finds files containing the keyword in the description field. Server-side searching is way faster than downloading metadata and parsing locally. Important: handle the description field properly since it can be null. I added a null check before the keyword search to prevent errors. This scales well with thousands of files because Google’s servers do the heavy lifting, not your script.
Estás intentando crear un reporte en Google Sheets que cuente la frecuencia de palabras clave específicas (@keywords) en las descripciones de archivos almacenados en una carpeta de Google Drive, incluyendo subcarpetas. Necesitas conectar Google Sheets con los metadatos de los archivos de Google Drive para lograr este conteo automatizado.
Understanding the “Why” (The Root Cause):
Google Sheets no puede acceder directamente a los metadatos de los archivos de Google Drive desde sus fórmulas integradas. Para lograr el conteo automatizado de palabras clave en las descripciones de archivos de Drive, necesitas un proceso que extraiga esos metadatos, los procese y luego los importe a tu hoja de cálculo. Las fórmulas de Google Sheets por sí solas son insuficientes para esta tarea ya que requieren una interacción directa con la API de Google Drive.
Step-by-Step Guide:
Automatiza la extracción de metadatos: En lugar de intentar manipular la API de Google Drive directamente dentro de Google Sheets, utiliza una herramienta de automatización que se integre con ambas plataformas. Herramientas como Latenode ofrecen nodos preconstruidos para interactuar con la API de Google Drive y Google Sheets, simplificando enormemente el proceso.
Crea un flujo de trabajo: En la plataforma de automatización (ej., Latenode), configura un flujo de trabajo con los siguientes pasos:
Conexión a Google Drive: Autentica la conexión a tu cuenta de Google Drive, otorgando los permisos necesarios para leer los metadatos de los archivos.
Especifica la carpeta: Define la carpeta principal de Google Drive que contiene los archivos que deseas analizar. La herramienta de automatización debe poder buscar recursivamente en las subcarpetas.
Extrae los metadatos: Configura un nodo que extraiga los metadatos de cada archivo en la carpeta especificada, incluyendo la descripción del archivo.
Procesa las palabras clave: Utiliza un nodo de procesamiento de texto (ej., un nodo de expresiones regulares) para extraer las palabras clave que comienzan con “@” de la descripción de cada archivo.
Cuenta las palabras clave: Agrega un nodo que cuente la frecuencia de cada palabra clave.
Importa a Google Sheets: Finalmente, utiliza un nodo de integración con Google Sheets para importar los resultados del conteo en tu hoja de cálculo. Define las columnas correspondientes para cada palabra clave y sus conteos.
Configura la ejecución: Configura el flujo de trabajo para que se ejecute de manera periódica (ej., diariamente) o según un trigger (ej., cuando se agrega un nuevo archivo a la carpeta). Esto asegura que tu reporte en Google Sheets se mantenga actualizado.
Verifica los resultados: Después de la primera ejecución, verifica los resultados en tu hoja de cálculo para asegurarte de que el conteo sea preciso. Ajusta tu flujo de trabajo si es necesario.
Common Pitfalls & What to Check Next:
Permisos de la API: Asegúrate de que tu herramienta de automatización tenga los permisos necesarios para acceder a Google Drive y Google Sheets.
Límites de la API: La API de Google Drive tiene límites de tasa. Si tienes una gran cantidad de archivos, es posible que necesites ajustar la frecuencia de ejecución de tu flujo de trabajo o implementar un mecanismo de paginación en la extracción de metadatos.
Manejo de errores: Implementa un manejo de errores robusto en tu flujo de trabajo para poder detectar y manejar problemas como errores de conexión o archivos con descripciones faltantes.
Formato de datos: Asegúrate de que el formato de los datos importados a Google Sheets sea el adecuado para su posterior análisis.
Still running into issues? Share your (sanitized) config files, the exact command you ran, and any other relevant details. The community is here to help!
Been there. Apps Script works but it’s a pain to maintain. You’ll hit rate limits, deal with API changes, and spend way too much time debugging.
Your real problem is needing reliable background data collection. Sheets formulas can’t grab Drive metadata from nested folders. Custom functions also struggle with recursive scanning and API quotas.
You need something that handles this outside Sheets entirely. Connect to Google Drive API, scan subfolders recursively, pull file descriptions, parse @ keywords with regex, count them, then dump clean data into your spreadsheet.
I built this exact thing for document compliance tracking. Runs nightly, processes thousands of files across dozens of nested folders, fills our reporting sheet with fresh keyword counts.
No timeouts, no quota issues, no manual triggers. Just reliable data collection that keeps your sheet updated automatically.
Latenode handles the Drive scanning and Sheets integration with pre-built nodes. Much cleaner than wrestling with Apps Script.