Tengo un formulario que contiene preguntas.
Depende en gran medida de cómo se vea su formulario.
Aquí hay un ejemplo de cómo se podría hacer.
Supongamos que tiene un formulario muy simple como este:
Tiene dos 'valores con nombre': Folder y File , se utilizarán en el siguiente script.
Siguiente paso: debe agregar una hoja de cálculo 'vinculada' al formulario.
En esta hoja de cálculo, debe agregar este script:
// names and IDs of your destination folders var folders = { 'aaa' : '###', // <-- you have to change ### with a real ID 'bbb' : '###', 'ccc' : '###' } function move_file_to_folder(e) { // get folder ID from folders object var folder_id = folders[e.namedValues['Folder'][0]]; // <-- the name from the named value 'Folder' // get file ID from the form var file_id = e.namedValues['File'][0].split('id=')[1]; // <-- the url from the named value 'File' // move the file into the folder DriveApp.getFileById(file_id).moveTo(DriveApp.getFolderById(folder_id)); } // this function should be run just once to install the trigger function install_OnFormSubmitTrigger() { var ss = SpreadsheetApp.getActive(); ScriptApp.newTrigger('move_file_to_folder') .forSpreadsheet(ss) .onFormSubmit() .create(); } Después de eso, debe ejecutar la función install_OnFormSubmitTrigger() para instalar el activador.
Probablemente tenga sentido ejecutar la función move_file_to_folder() también, para obtener el acceso adecuado. Te dará un error. No te preocupes. Mantenga la calma y continúe.
Ahora, cada vez que envíe el formulario, el archivo cargado irá a una carpeta con el nombre respectivo ('aaa', 'bbb', 'ccc' en mi ejemplo).