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

230
Vistas
Save Gmail attachment to SHARED Google Drive

Goal: Update code below to save attachments to a "Test" folder within "Shared drive"

So far I've been successful in saving attachments to "My Drive" using the gmail2gdrive script found on https://github.com/ahochsteger/gmail2gdrive

This script uses DriveApp.getRootFolder() to find the root folder, but does not look at shared drives.
I have the "Drive" Advanced Service set up and am able to at least view up to 10 folders in the Shared Drive using getSharedDrives(), but have been unsuccessful updating the code to transfer files to a shared drives.

about 4 years ago · Santiago Gelvez
2 Respuestas
Responde la pregunta

0

Move a file from MyDrive to Shared Drive

function movefileToSharedDrive() {
  const file = DriveApp.getFileById('');//fileid
  const fldr = DriveApp.getFolderById('');//shared drive id
  Drive.Files.update({"parents": [{"id": fldr.getId()}]}, file.getId(), null, {"supportsAllDrives":true});
}

Drive API Version 2 needs to be enabled

about 4 years ago · Santiago Gelvez Denunciar

0

The Folder Drive ID can be found in the URL extension: Folder Drive ID

Use the folders' Drive IDs (from above) to fill in the appropriate section of the code below (Copies files from desired folder into the shared folder):

function movefileToSharedDrive() {
  makeCopy("", ""); //("From My Drive ID", "To Shared Drive ID")
}

function makeCopy(srcFolderId, dstFolderId) {
  var srcFolder = DriveApp.getFolderById(srcFolderId);
  var dstFolder = DriveApp.getFolderById(dstFolderId);
  var files = srcFolder.getFiles();
  while (files.hasNext()) {
    var file = files.next();
    var f = file.makeCopy(dstFolder);
    if (file.getMimeType() == MimeType.GOOGLE_APPS_SCRIPT) {
      Drive.Files.update({"parents": [{"id": dstFolderId}]}, f.getId());
    }
  }
}
about 4 years ago · Santiago Gelvez 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