Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

239
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda