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

160
Visualizações
App Script + Forms: How to move upload files

I have a Form bound to a Sheet. That works fine. I need to move the uploads to the newFolder and delete them from the temp holding folder. I have the ID for the temp holding folder(s). And I have the ID for the newFolder. There is only 1 uploaded file per folder (3 folders in total), so I am not working with a list within the temp folders. I do have the link in the Sheet for each file but I have no idea how to utilize this.

I tried copying the files but I can not obtain the file name or ID as it is always different with each form submission. The below is my latest attempt but I think I am messing something up with the nested function. Also unlike python I don't know how to pass the value of the newFolder from the previous function.

Also I am unsure if I should use a loop to iterate through the 3 folders. I have no idea how to form a loop in App Script even after reviewing some examples. Maybe because I'm hung up on moving the files first. Maybe a loop is not need as it is always the same number of folders and files.

So I could use some help sorting this out.

Thanks

//this part works great
function autoFillForm(e) {
  
  var timestamp = e.values[0];
  var firstName = e.values[1];
  var lastName = e.values[2];
  var title = e.values[3];
  

 //create new folder
  var parentFolder = DriveApp.getFolderById('My Parent Folder ID');
  var newFolder = parentFolder.createFolder(lastName + ' - ' + firstName);


  //Get template
  var file = DriveApp.getFileById('My Template ID'); 
  

  //Copy template, name it, save to new folder
  var copy = file.makeCopy(lastName + ',' + firstName + ' - ' + 'Template Name', newFolder); 
  
  //Open copied file
  var doc = DocumentApp.openById(copy.getId()); 
  
  //Get Template body
  var body = doc.getBody(); 
  
  //Replace text in template
  body.replaceText('{{fName}}', firstName);
  body.replaceText('{{lName}}', lastName);
  body.replaceText('{{title}}', title);
  
  //Save and close
  doc.saveAndClose(); 
  

  //where I am having issues
  function movingFiles {

  var source_folder1 = ('ID OF Temp Folder');
  var dest_folder = (newFolder);
  var files = source_folder1.getFiles();

  while (files.hasNext()) {
    var file = files.next();
    dest_folder.addFile(file);
    source_folder1.removeFile(file);
  }

}

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