Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

404
Vistas
Find Files in a Shared Drive with Apps Script

This code search for some files inside a folder. It work good on my drive, but I need it for a shared folder in my company and it does not get file names and ids. I've read about {supportsAllDrives: true} but I don't know how to implement it in the code (I don't even know if its the solution). Drive API and DriveActivity API are enabled in my project.

var expFolder = carpetabasecs.searchFolders(searchFor);
  while (expFolder.hasNext()) {
var expFolderDef = expFolder.next();
var expFolderId = expFolderDef.getId();

var mask = 'TXT';
var query = `title contains "${mask}" and trashed = false and "${expFolderId}" in parents`;
var findings = Drive.Files.list({ q: query }) || [];
var table = [['Archivos exportados', 'IDs'], ...findings.items.map(f => [f.title, f.id]).sort()];

sh.getRange(2,1,table.length,2).setValues(table);

Thanks

about 4 years ago · Juan Pablo Isaza
3 Respuestas
Responde la pregunta

0

Did you try like this?

var findings = Drive.Files.list( { 
    q: query,
    useDomainAdminAccess: true
  }) || [];
about 4 years ago · Juan Pablo Isaza Denunciar

0

Change this:

var findings = Drive.Files.list({ q: query }) || [];

To this:

var findings = Drive.Files.list({ q: query, supportsAllDrives: true }) || [];

Remember that you are using the Drive v2 (not v3)

Documentation
  • Drive.File.list (v2)
about 4 years ago · Juan Pablo Isaza Denunciar

0

Finally I'm using this method to filter the files. It's working good on shared drives.

  var sufix = 'TXT' // adapt as necessary
  var list = [];
  var files = expFolderDef.getFiles();
  while (files.hasNext()) {
    file = files.next();
    list.push([file.getName(),file.getId()])
  }
  var result = [['Archivos exportados','IDs'], ...list.filter(r => r[0].includes(sufix)).sort()]
  sh.getRange(2,1, result.length, result[0].length).setValues(result);

Anyway I'm still interested in understand how to use the Drive.Files.list command, useDomaininAdminAccess and supportAllDrives don't make the work. I've read that the command is in Advanced Drive Service, that API is the same as Drive API? Because I can't find Advanced Drive Service in Cloud Services.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda