I have a google form that has two file upload sections. I want to be able to upload those files to two different folders. The files in the first file upload section should go in Folder one and the files in the second file upload section should go in folder two. I also want to automatically name the folders based on the name of the senders. Folders should go as follow: sendername_1, sendername_2, etc, if the senders have the same name. How would I make this happen? I found the script below but it seems to only work with folder 1. Folder 2 has the files from the second file upload section but it doesn't automatically create a folder for them.
function onFormSubmit(e) {
const folderId = "1y40PNXYXSm7Ue_b6nbVnauz7dzKiKj4u"; // Please set top folder ID of the destination folders.
const form = FormApp.getActiveForm();
const formResponses = form.getResponses();
const itemResponses = formResponses[formResponses.length-1].getItemResponses();
Utilities.sleep(3000); // This line might not be required.
// Prepare the folder.
const destFolder = DriveApp.getFolderById(folderId);
const folderName = itemResponses[0].getResponse();
const subFolder = destFolder.getFoldersByName(folderName);
const folder = subFolder.hasNext() ? subFolder : destFolder.createFolder(folderName);
// Move files to the folder.
itemResponses[2].getResponse().forEach(id => DriveApp.getFileById(id).moveTo(folder));
}