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

366
Visualizações
Move Folders in Google Drive Using Google Apps Script

I was wondering if someone could take a look at this for me.

  • The goal

My company has a ton of client folders on google drive that are full of content (files and folders). I'm trying to take all of the existing content, and move it into a newly created folder within each client folder named "old client work".

  • The issue

When I run the code, there's an issue with moving folders. Creating the "old client work" folder works fine, as does moving existing files into it. But the code runs into an error when trying to move folders.

  • The code

Here is the code I have:

function createOldClientWorkFolder() {
    var clientContentFolder = DriveApp.getFolderById("IDhere");
    var clientFolders = clientContentFolder.getFolders();
    while(clientFolders.hasNext()) {
        var client = clientFolders.next();
        var oldWorkFolder = client.createFolder('Old Client Work');
        var clientContentFiles = client.getFiles();
        var clientContentFolders = client.getFolders();
        while (clientContentFiles.hasNext()) {
              var fileToMove = clientContentFiles.next();
              fileToMove.moveTo(oldWorkFolder)
        }

        while (clientContentFolders.hasNext()) {
              var folderToMove = clientContentFolders.next();
              folderToMove.moveTo(oldWorkFolder)
        }


    }

}

Any help would be appreciated!

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

(Since you haven't provided a log/error message I'm guessing here, but I encountered something similar a while ago while trying to move folders so I thought this might help.)

moveTo requires that you have permission to the object that you're trying to move itself. Could there be a possibility that your app script doesn't have the write permission to the actual client folder? (moveTo modifies the parent property of the folder object you're trying to move, so you also read write permission, not just read).

about 4 years ago · Juan Pablo Isaza 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