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

362
Vistas
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 Respuestas
Responde la pregunta

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 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