function convertCSVFilesToSheets() { var folderId = "DRIVE_FOLDER_ID"; // Replace with the ID of your folder var spreadsheetId = "SHEET_ID"; // Replace with the ID of your spreadsheet var folder = DriveApp.getFolderById(folderId); var files = folder.getFiles(); var spreadsheet = SpreadsheetApp.openById(spreadsheetId); while (files.hasNext()) { var file = files.next(); if (file.getMimeType() == "text/csv") { var csvData = file.getBlob().getDataAsString(); var csvLines = csvData.split('\n'); var sheet = spreadsheet.insertSheet(file.getName()); for (var i = 0; i < csvLines.length; i++) { var rowData = csvLines[i].split(','); sheet.getRange(i + 1, 1, 1, rowData.length).setValues([rowData]); } } } }